Notification Service Extension
Create and configure a Notification Service Extension to support rich media attachments like images, animated GIFs, and videos in push notifications.
To support rich media attachments (images, animated GIFs, video) in push notifications, you need to create a notification service extension .
Create a Notification Service Extension Target
- In Xcode, click File → New → Target….
- Select Notification Service Extension.
- Click Next and configure your extension:
- Product Name: Your extension name (e.g.,
NotificationServiceExtension) - Bundle Identifier: Typically your app’s bundle ID with a suffix (e.g.,
com.example.app.NotificationServiceExtension)
- Product Name: Your extension name (e.g.,

- Verify that your app target’s Embed App Extensions includes the newly created extension.

Install Dependencies
Install Notification Service Extension
- Select your service extension target in the Project Navigator.
- Go to the Package Dependencies tab.
- If you haven’t already added the Airship package, click + and add:
https://github.com/urbanairship/ios-library - Select the
AirshipNotificationServiceExtensionpackage product for your service extension target.
The AirshipNotificationServiceExtension package should only be added to the Notification Service Extension target, not the main app target.
- Import the module:
import AirshipNotificationServiceExtensionAdd to your Podfile:
target "<Your Service Extension Target Name>" do
pod 'AirshipServiceExtension'
endInstall:
$ pod install- Add
AirshipNotificationServiceExtension.frameworkto your service extension target following Carthage’s instructions . - Add to your
Cartfile:
github "urbanairship/ios-library"- Build:
$ carthage update- Verify that Enable Modules and Link Frameworks Automatically are enabled in Build Settings.
- Download the latest iOS SDK release .
- Add
AirshipNotificationServiceExtension.xcframeworkto your service extension target:- Select your service extension target
- Go to General → Frameworks, Libraries, and Embedded Content
- Drag in
AirshipNotificationServiceExtension.xcframework
- Verify Build Settings:
- Enable Modules:
Yes - Link Frameworks Automatically:
Yes
- Enable Modules:
Implement the Service Extension
Replace the default NotificationService implementation with Airship’s base class:
Service Extension Implementation
import AirshipNotificationServiceExtension
class NotificationService: UANotificationServiceExtension {
}import AirshipServiceExtension
class NotificationService: UANotificationServiceExtension {
}// NotificationService.h
@import AirshipNotificationServiceExtension;
@interface NotificationService : UANotificationServiceExtension
@end
// NotificationService.m
@import Foundation;
#import "NotificationService.h"
@implementation NotificationService
@end// NotificationService.h
@import AirshipServiceExtension;
@interface NotificationService : UANotificationServiceExtension
@end
// NotificationService.m
@import Foundation;
#import "NotificationService.h"
@implementation NotificationService
@endThat’s it! The Airship base class handles downloading and attaching media from URLs in your push notifications. When you send a push notification with a media URL, the service extension will automatically download and attach the media before the notification is displayed.
Related Documentation
Categories