Created
March 7, 2018 23:52
-
-
Save welbesw/68f353b101e0dab307961c4999833479 to your computer and use it in GitHub Desktop.
Push Assign UNUserNotificationCenter delegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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