gpt4 book ai didi

ios - 从不同的应用委托(delegate)函数调用 didRegisterUserNotificationSettings

转载 作者:行者123 更新时间:2023-11-28 09:11:55 30 4
gpt4 key购买 nike

我正在为我的应用程序添加入门指南,并希望用户在指南的特定幻灯片上注册通知。我想知道是否有办法从我的入职功能中调用 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

最佳答案

是的,有。当您在“指南的特定幻灯片”中时调用 registerForNotificationTypes:

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

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

编辑

这是你应该如何注册

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

关于ios - 从不同的应用委托(delegate)函数调用 didRegisterUserNotificationSettings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29106571/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com