map-o file-code-o arrow-directionplatform-webreach-project-type-boarding-passreach-project-type-couponreach-project-type-event-ticketreach-project-type-genericreach-project-type-gift-cardreach-project-type-loyalty-cardreach-project-type-member-card pictures more_vert chain keyboard_arrow_down keyboard_arrow_right

iOS Notification Service Extension

In order to take advantage of iOS 10 notification attachments, such as images, animated gifs, and video, you will need to create a notification service extension.

Create a new iOS target in Xcode

In Xcode, click the File menu, select New » Target…, then click the Notification Service Extension template.


Typically extensions are named with a suffix on the main application’s ID. In this example the bundle identifier would be com.urbanairship.sample.ExampleServiceExtension.

Check that your app’s target Embed App Extensions contains your newly created extension.

Install AirshipAppExtensions

CocoaPods

Example podfile:

target "SampleExtension" do
  pod 'UrbanAirship-iOS-AppExtensions'
end

Update installed pods:

$ pod install

Install using the following command:

Specify the UrbanAirship-iOS-AppExtensions in your podfile and your newly created service extension as the target. Make sure to run pod install after modifying the podfile.

Carthage

Before you begin, ensure you have Carthage installed.

Adding the SDK framework to your application

Specify the Urban Airship iOS SDK in your cartfile:

github "urbanairship/ios-library"

Follow Carthage’s adding frameworks to an application instructions to add AirshipAppExtensions.framework to your application.

If you are also using the Urban Airship SDK, follow the instructions in the iOS SDK Guide.

Verify Enable Modules and Link Frameworks Automatically are enabled in the project’s Build Settings.

Manual

Drag the AirshipAppExtensions.framework into your app project from iOS SDK.


Add AirshipAppExtensions to Target Dependencies in your project’s Build Phases.


Add AirshipAppExtensions.framework to a Copy Files phase in your project’s Build Phases. Ensure “Frameworks” is set as the destination.


Link against AirshipAppExtensions.framework in your extension’s Build Phases.

Modify the Extension

Extension:

// Notification.swift
import AirshipAppExtensions class NotificationService: UAMediaAttachmentExtension {

}
// NotificationService.h
@import AirshipAppExtensions;

@interface NotificationService : UAMediaAttachmentExtension

@end

// NotificationService.m
@import Foundation;

#import "NotificationService.h" @implementation NotificationService

@end

Delete all dummy source code for your new extension and inherit from UAMediaAttachmentExtension in NotificationService.

Never miss out on product updates

Click "Allow" in the browser prompt in the upper left hand corner of your browser.

Next, we'll allow you to choose what sort of notifications you'd like to receive.

Choose your notification topics

Product Subscription Options

    Platform Subscription Options