Questions tagged «unusernotificationcenter»

11
在Xcode 8 / Swift 3.0中注册推送通知?
我正在尝试让我的应用程序在Xcode 8.0中运行,并且遇到错误。我知道这段代码在swift的早期版本中可以正常工作,但是我假设在新版本中对此代码进行了更改。这是我要运行的代码: let settings = UIUserNotificationSettings(forTypes: [.Sound, .Alert, .Badge], categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings) UIApplication.shared().registerForRemoteNotifications() 我收到的错误是“参数标签'(forTypes :, Categories :)'与任何可用的重载都不匹配” 我可以尝试使用其他命令来使其正常工作吗?

7
UIApplication.registerForRemoteNotifications()必须仅从主线程调用
Xcode 9(iOS 11)向我显示了注册推送(远程)通知时的错误/警告。 这是错误消息 这是代码,我已经尝试过: let center = UNUserNotificationCenter.current() center.delegate = self center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in if error == nil{ UIApplication.shared.registerForRemoteNotifications() } } 错误/警告行: UIApplication.shared.registerForRemoteNotifications() 如何解决呢?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.