我正在尝试实现本地通知,但收到了错误消息"Type of Expression is Ambiguous More Context“。
我看过其他相关的主题,其中很多都是使用早期版本的Xcode (我使用的是8.o,iOS10),或者提供了我遇到问题的同一段代码。如果我错过了一篇关于答案的帖子,我向你道歉。我从tutorial site复制并粘贴了这段代码,它似乎与许多其他站点上使用的代码相同(并作为其他问题的答案提供)。
此代码用于请求用户对本地通知的权限
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.registerUserNotificationSettings(UNNotificationSettings(forTypes: [.Alert , .Badge , .Sound], categories: nil)) // This line sends back the error
return true
}
谢谢!
发布于 2017-04-28 03:27:03
根据Swift 3和iOS 10,执行以下操作:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound], completionHandler: nil)
return true
}
https://stackoverflow.com/questions/43671249
复制相似问题