【发布时间】:2017-01-15 06:25:39
【问题描述】:
我有一个应用程序,当我发送推送通知时,它会向我发送设备的位置。但是,当应用在前台运行时,应用会在收到推送通知时崩溃。
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler:(UIBackgroundFetchResult) -> Void )
{
NSLog("\(userInfo)")
if (managedConfig["locationTrackingDisabled"] ?? false) as! Bool == false {
locationManager.startUpdatingLocation()
}
let seconds = 4.0
let delay = seconds * Double(NSEC_PER_SEC) // nanoseconds per seconds
let dispatchTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
completionHandler(UIBackgroundFetchResult.NewData)
})
}
【问题讨论】:
-
你遇到了什么错误?
-
因为我正在使用 APNS,所以我正在创建一个 .ipa 并安装在我的设备上。不生成任何日志。
-
为什么不创建开发证书,然后在设备上进行测试?
标签: ios iphone swift push-notification apple-push-notifications