ibm-bluemix-mobile-services/bms-clientsdk-swift-push

Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]

Closed this issue · 5 comments

I am getting the following warning:

Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
PID: 926, TID: 418478, Thread name: (none), Queue name: com.apple.usernotifications.UNUserNotificationServiceConnection.call-out, QoS: 0
Backtrace:
4 BMSPush 0x0000000109b44b7c _T07BMSPush0A6ClientC21initializeWithAppGUIDySS03appF0_SS12clientSecretAA0aB7OptionsC7optionstFySb_s5Error_pSgtcfU_Tf4ngg_n + 92
5 BMSPush 0x0000000109b4d3f4 _T07BMSPush0A6ClientC21initializeWithAppGUIDySS03appF0_SS12clientSecretAA0aB7OptionsC7optionstFySb_s5Error_pSgtcfU_TA + 60
6 BMSPush 0x0000000109b3b184 _T0Sbs5Error_pSgIxyx_SbSo7NSErrorCSgIyByy_TR + 60
7 libdispatch.dylib 0x000000010bee149c _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x000000010bee145c _dispatch_client_callout + 16
9 libdispatch.dylib 0x000000010bef0110 _dispatch_queue_serial_drain + 692
10 libdispatch.dylib 0x000000010bee49a4 _dispatch_queue_invoke + 332
11 libdispatch.dylib 0x000000010bef1104 _dispatch_root_queue_drain_deferred_wlh + 424
12 libdispatch.dylib 0x000000010bef8100 _dispatch_workloop_worker_thread + 652
13 libsystem_pthread.dylib 0x0000000182b6afe0 _pthread_wqthread + 932
14 libsystem_pthread.dylib 0x0000000182b6ac30 start_wqthread + 4
2017-09-15 09:50:36.976211+0300 KiteSpotter[926:418478] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
PID: 926, TID: 418478, Thread name: (none), Queue name: com.apple.usernotifications.UNUserNotificationServiceConnection.call-out, QoS: 0
Backtrace:
4 BMSPush 0x0000000109b44b7c _T07BMSPush0A6ClientC21initializeWithAppGUIDySS03appF0_SS12clientSecretAA0aB7OptionsC7optionstFySb_s5Error_pSgtcfU_Tf4ngg_n + 92
5 BMSPush 0x0000000109b4d3f4 _T07BMSPush0A6ClientC21initializeWithAppGUIDySS03appF0_SS12clientSecretAA0aB7OptionsC7optionstFySb_s5Error_pSgtcfU_TA + 60
6 BMSPush 0x0000000109b3b184 _T0Sbs5Error_pSgIxyx_SbSo7NSErrorCSgIyByy_TR + 60
7 libdispatch.dylib 0x000000010bee149c _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x000000010bee145c _dispatch_client_callout + 16
9 libdispatch.dylib 0x000000010bef0110 _dispatch_queue_serial_drain + 692
10 libdispatch.dylib 0x000000010bee49a4 _dispatch_queue_invoke + 332
11 libdispatch.dylib 0x000000010bef1104 _dispatch_root_queue_drain_deferred_wlh + 424
12 libdispatch.dylib 0x000000010bef8100 _dispatch_workloop_worker_thread + 652
13 libsystem_pthread.dylib 0x0000000182b6afe0 _pthread_wqthread + 932
14 libsystem_pthread.dylib 0x0000000182b6ac30 start_wqthread + 4

screen shot 2017-09-15 at 10 29 36

@zirinisp Are you calling the init method in main thread ?

@AnanthaKrish Apologies for the later reply. All calls happen on the main thread:

screen shot 2017-10-04 at 19 32 00

screen shot 2017-10-04 at 19 29 47

@zirinisp Are you using Xcode 9 and swift 4 ?

@AnanthaKrish I'm getting the same warning with Xcode 9 and Swift 4.

If you can make your calls to UIApplication.shared.registerForRemoteNotifications() on the main thread in BMSPushClinet.swift it will resolve this issue:

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

@tonykambo Yeah, we are working on the swift4 version of the SDK. Will release the SDK soon. 👍