UIApplication.registerForRemoteNotifications() must be called from main thread only

前端 未结 7 1261
猫巷女王i
猫巷女王i 2020-11-30 00:23

Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification.

Here is error message

And here is code, I\'ve tried:<

7条回答
  •  日久生厌
    2020-11-30 00:44

    In swift4

    You can solve this issue with

    DispatchQueue.main.async {
      UIApplication.shared.registerForRemoteNotifications()
    }
    

    Hope this will help...

提交回复
热议问题