Skip to content

Instantly share code, notes, and snippets.

@welbesw
Created March 7, 2018 23:52
Show Gist options
  • Save welbesw/68f353b101e0dab307961c4999833479 to your computer and use it in GitHub Desktop.
Save welbesw/68f353b101e0dab307961c4999833479 to your computer and use it in GitHub Desktop.
Push Assign UNUserNotificationCenter delegate
import UIKit
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Assign the push delegate before didFinishLaunchingWithOptions completes
UNUserNotificationCenter.current().delegate = PushManager.sharedInstance
PushManager.sharedInstance.registerForPushNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
PushManager.sharedInstance.didRegisterForRemoteNotifications(deviceToken: deviceToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("didFailToRegisterForRemoteNotificationsWithError: \(error)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment