gpt4 book ai didi

ios - 请求接收推送操作的权限

转载 作者:行者123 更新时间:2023-11-29 02:10:59 26 4
gpt4 key购买 nike

我只想在用户按下 ViewController 中的按钮后询问用户的许可。我该怎么做?

应用程序启动后,在我的代码对话框弹出窗口中。除了 AppDelegate 类之外,我无法在任何地方执行 application.registerUserNotificationSettings(我总是出错)。

AppDelegate.swift:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

// Notifications
let notificationType = UIUserNotificationType.Alert
let settings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
application.registerUserNotificationSettings(settings) // <-- that method popups dialog to allow/decline Push

// Override point for customization after application launch.
return true
}

最佳答案

您可以在您想要的地方使用它:

UIApplication.sharedApplication().registerUserNotificationSettings(设置)

关于ios - 请求接收推送操作的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29289829/

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