IOS - scheduleLocalNotification 生产
IOS - scheduleLocalNotification on production
我正在使用 AppDelefate 的 UILocalNotification 的 scheduleLocalNotification,在调试提供方面一切顺利。
但是,当我在 Ad Hoc 条款上测试我的应用程序时 - 它不会触发通知。
有人可以指导我吗?
谢谢!
首先 - 本地通知不依赖于配置文件。你错过了 PushNotifications。
您确定要安排通知吗?也许您忘记了请求用户许可?
它应该是这样的:
if #available(iOS 8.0, *) {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound, categories: nil))
let notification = UILocalNotification()
notification.alertBody = "body"
notification.alertAction = "open"
notification.fireDate = NSDate().dateByAddingTimeInterval(60)
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["myKey": "myValue"]
notification.category = "category"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
} else {
// do nothing
// iOS 7 and prior does not require permission
}
我正在使用 AppDelefate 的 UILocalNotification 的 scheduleLocalNotification,在调试提供方面一切顺利。 但是,当我在 Ad Hoc 条款上测试我的应用程序时 - 它不会触发通知。 有人可以指导我吗? 谢谢!
首先 - 本地通知不依赖于配置文件。你错过了 PushNotifications。
您确定要安排通知吗?也许您忘记了请求用户许可?
它应该是这样的:
if #available(iOS 8.0, *) {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound, categories: nil))
let notification = UILocalNotification()
notification.alertBody = "body"
notification.alertAction = "open"
notification.fireDate = NSDate().dateByAddingTimeInterval(60)
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["myKey": "myValue"]
notification.category = "category"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
} else {
// do nothing
// iOS 7 and prior does not require permission
}