Skip to content

Instantly share code, notes, and snippets.

@ysam12345
Created January 9, 2019 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysam12345/ce31a59e854f2d386438ec03aa24da66 to your computer and use it in GitHub Desktop.
Save ysam12345/ce31a59e854f2d386438ec03aa24da66 to your computer and use it in GitHub Desktop.
//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