...
A sampleĀ AppDelegate file is as follows.
Wiki Markupcode | ||||
---|---|---|---|---|
| ||||
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, UARegistrationDelegate, UAPushNotificationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { let config = UAConfig.default() UAirship.takeOff(config) UAirship.push().notificationOptions = [.alert, .badge, .sound] UAirship.push().userPushNotificationsEnabled = true UAirship.push().registrationDelegate = self UAirship.push().pushNotificationDelegate = self return true } func registrationSucceeded(forChannelID channelID: String, deviceToken: String) { print("Registration succeeded. ChannelID: \(channelID), DeviceToken: \(deviceToken)") // TODO: Register DeviceID with RubiqAPI } func receivedForegroundNotification(_ notificationContent: UANotificationContent, completionHandler: @escaping () -> Void) { print("Received foreground notification. DeviceToken: \(UAirship.push().deviceToken)") } @available(iOS 10.0, *) func presentationOptions(for notification: UNNotification) -> UNNotificationPresentationOptions { print("Presentation options") return [.alert, .sound] } func receivedBackgroundNotification(_ notificationContent: UANotificationContent, completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { print("Received background notification. DeviceToken: \(UAirship.push().deviceToken)") } } |
...