Example of usage:
/* Instance of your custom APNs/local notification manager */
private var pushManager: AppleNotificationManager!
Registration:
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
// Called to tell the delegate the types of notifications that can be used to get the user’s attention
pushManager.didRegisterSettings(notificationSettings)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
// Tells the delegate that the app successfully registered with Apple Push Notification service (APNs)
pushManager.didRegisterDeviceToken(deviceToken)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
// Sent to the delegate when Apple Push Notification service cannot successfully complete the registration process.
pushManager.didFailToRegisterDeviceToken(error)
}
Remote notifications handling:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
// Remote notification arrived, there is data to be fetched
// Handling it
pushManager.handleNotification(userInfo,
background: application.applicationState == .Background
)
}
Local notifications handling:
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
pushManager.handleLocalNotification(notification, background: false)
}
Handling action (deprecated):
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject],
completionHandler: () -> Void) {
pushManager.handleInteractiveRemoteNotification(userInfo, actionIdentifier: identifier, completion: completionHandler)
}