从不同的应用委托函数调用 didRegisterUserNotificationSettings

call didRegisterUserNotificationSettings from a different app delegate function

我正在向我的应用程序添加入门指南,并希望用户在指南的特定幻灯片上注册通知。我想知道是否有办法从我的入职功能中调用 didRegisterUserNotificationSettings 功能。如果我不能直接调用它,有没有办法创建一个不同的函数来执行相同的功能并且可以被我的入职函数调用?

编辑 我刚刚添加了

 let notificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
        UIApplication.registerUserNotificationSettings(settings)

我现在收到以下错误

Uiusernotificationsettings is not convertible to uiapplication

是的,有。在 "specific slide of the guide" 中时调用 registerForNotificationTypes:

但是,弹出窗口只出现一次。如果用户,上帝保佑,已经禁用了您应用程序的通知,最多,您可以给他一个选项,将他带到他应该手动启用它的设置页面。 (确保你不会因此太烦他。)

请注意,调用 didRegisterUserNotificationSettings: 是没有用的,因为它是在您的应用成功注册通知时调用的委托方法。

编辑

这就是您应该如何注册

UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()