获取推送通知允许按钮的操作

时间:2019-03-26 06:27:14

标签: ios swift iphone push-notification

我正在开发ios应用程序, 现在我要执行推送通知的“允许”按钮的操作, 一旦用户选择了一个推送通知选项(不允许,允许),用户就会被推送到第二个视图控制器。

1 个答案:

答案 0 :(得分:0)

您需要在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")
        }