在didRegisterForRemoteNotification中执行自定义操作时崩溃

时间:2018-12-07 12:56:33

标签: ios swift appdelegate

发生的崩溃是:-

Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001004c6514

以下是崩溃的堆栈竞赛:-

 Crashed: com.apple.main-thread
0  Quickride                      0x1004c6514 specialized static HttpUtils.putJSONRequestWithBody(url:targetViewController:handler:body:) (HttpUtils.swift:173)
1  Quickride                      0x100464958 specialized static UserRestClient.saveDeviceToken(targetViewController:requestBody:completionHandler:) (UserRestClient.swift:421)
2  Quickride                      0x100746da8 DeviceRegistrationHelper.registerDeviceTokenWithQRServer() (DeviceRegistrationHelper.swift:33)
3  Quickride                      0x1007fef14 specialized AppDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:) (AppDelegate.swift:315)
4  Quickride                      0x1007f3714 @objc AppDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:) (AppDelegate.swift)
5  FBSDKCoreKit                   0x101b350f4 fb_swizzledMethod_4 + 140
6  libdispatch.dylib              0x2284a56c8 _dispatch_call_block_and_release + 24
7  libdispatch.dylib              0x2284a6484 _dispatch_client_callout + 16
8  libdispatch.dylib              0x2284529b4 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
9  CoreFoundation                 0x2289fbdd0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
10 CoreFoundation                 0x2289f6c98 __CFRunLoopRun + 1964
11 CoreFoundation                 0x2289f61cc CFRunLoopRunSpecific + 436
12 GraphicsServices               0x22ac6d584 GSEventRunModal + 100
13 UIKitCore                      0x255af1054 UIApplicationMain + 212
14 Quickride                      0x10043568c main (AppDelegate.swift:29)
15 libdyld.dylib                  0x2284b6bb4 start + 4

发生崩溃的代码是:-

 static func putJSONRequestWithBody(url: String, targetViewController: UIViewController?, handler: @escaping RiderRideRestClient.responseJSONCompletionHandler,body : Dictionary<String, String>){
    AppDelegate.getAppDelegate().log.debug("")
    var authHeader = [String: String]()
    if SharedPreferenceHelper.getJWTAuthenticationToken() != nil{
        authHeader[Authorization] = SharedPreferenceHelper.getJWTAuthenticationToken()!
    }
}

这是应用程序委托didRegisterForremoteNotification的代码,上面的代码部分在内部调用:-

   func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    AppDelegate.getAppDelegate().log.debug("")
  let deviceTokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    AppDelegate.getAppDelegate().log.debug("\(deviceTokenString)")
    userDefaults.setValue(deviceTokenString, forKey: "deviceTokenString")
    let phone = QRSessionManager.getInstance()?.getUserId()
    if phone != nil && (phone!.count) > 1 && deviceTokenString != nil && !deviceTokenString.isEmpty{

        DeviceRegistrationHelper(sourceViewController: nil, phone: phone!, deviceToken: deviceTokenString).registerDeviceTokenWithQRServer()
    }
}

0 个答案:

没有答案