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

Create a Notification Service Extension

Create a new iOS target in Xcode (File -> New -> Target) and select the Notification Service Extension type. 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 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

Specify the Urban Airship iOS SDK in your cartfile:

github "urbanairship/ios-library"

Build modules:

carthage update

Add github "urbanairship/ios-library" to the cartfile if its not already added. Run carthage update to build all the defined modules in the cartfile.

Drag the built AirshipAppExtensions framework into your Xcode project from the Carthage build directory. Add AirshipAppExtensions framework to Target Dependencies in your projects’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.

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.