Created
January 9, 2019 04:01
-
-
Save ysam12345/ce31a59e854f2d386438ec03aa24da66 to your computer and use it in GitHub Desktop.
This file contains 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
//get notification device token | |
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
let deviceTokenString = deviceToken.reduce("") { | |
return $0 + String(format: "%02x", $1) | |
} | |
print(deviceTokenString) | |
//save device token | |
DeviceToken.save(deviceToken: DeviceToken(token: deviceTokenString)) | |
} | |
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | |
print("在前景收到通知...") | |
completionHandler([.badge, .sound, .alert]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment