【发布时间】:2019-08-16 11:21:02
【问题描述】:
我正在开发一个 ios 应用程序, 现在我想获得推送通知的允许按钮的操作, 一旦用户选择推送通知选项之一(不允许,允许),用户将被推送到第二个视图控制器。
【问题讨论】:
标签: ios swift iphone push-notification
我正在开发一个 ios 应用程序, 现在我想获得推送通知的允许按钮的操作, 一旦用户选择推送通知选项之一(不允许,允许),用户将被推送到第二个视图控制器。
【问题讨论】:
标签: ios swift iphone push-notification
您需要在 AppDelegate 类中调用这些方法。
//Ios 10 delegates for Push Notifications
func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping ( _ options: UNNotificationPresentationOptions) -> Void){
print("Handle push from foreground")
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void){
print("Handle push from background or closed")
}
【讨论】: