繁体   English   中英

申请通知权限注册后(不仅仅是应用程序启动后)

[英]Ask for Notification permission After sign up (not just after app starts)

我们可以更改Permission seek方法的默认行为(它在我们启动应用程序时出现)但我想在用户注册时显示它,我在appDelegate中这样做:

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

    let notificationSettings = UIUserNotificationSettings(
        forTypes: [.Badge, .Sound, .Alert], categories: nil)


    application.registerUserNotificationSettings(notificationSettings)

    return true
}

您可以将它放在您想要询问用户的不同类中,如下所示

let notificationSettings = UIUserNotificationSettings(
            forTypes: [.Badge, .Sound, .Alert], categories: nil)

UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM