首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS 9推送通知dyld`dyld_fatal_error:

iOS 9推送通知dyld`dyld_fatal_error:
EN

Stack Overflow用户
提问于 2017-11-09 18:49:41
回答 1查看 103关注 0票数 0

我在iOS设备上运行时收到推送通知错误。iOS的版本是9。在Xcode中,我的部署目标也设置为9.0。下面是我的AppDelegate代码,我还附上了error..Kindly帮助的快照

代码语言:javascript
复制
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
    UIApplication.shared.registerForRemoteNotifications()
    return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    var token = ""
    for i in 0..<deviceToken.count {
        token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
    }
    print("Registration succeeded! Token: ", token)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    print("APNs registration failed: \(error)")
}
func showAlertAppDelegate(title: String,message : String,buttonTitle: String,window: UIWindow){
    let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
    alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertActionStyle.default, handler: nil))
    window.rootViewController?.present(alert, animated: false, completion: nil)
}

enter image description here

EN

回答 1

Stack Overflow用户

发布于 2017-11-09 19:06:04

尝试将tokenString的转换替换为以下行:

代码语言:javascript
复制
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})

我建议您使用异常断点来获取有关错误的更多信息。下面是a link如何使用它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47199914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档