3

I am working on core data and silent notifications. I don't have any thread safe implementation in core data. And when i get silent notifications i need to fetch & save couple of items into database.

So my question is does didReceiveRemoteNotification:fetchCompletionHandler always works on main thread? (Even the app is on background).

I did the experimentation, i sent silent notification when app is on the background, didReceiveRemoteNotification triggered in Thread 1(UIThread).

But still i want to make sure and prevent crashes related with thread issues.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0)
{

}
Arda Dtmr
  • 125
  • 2
  • 10
  • you can check using . . . if ([NSThread isMainThread]) { NSLog(@"Main Thread"); } else NSLog(@"Not on Main Thread"); – Nisar Ahmad Mar 20 '18 at 15:41
  • Duplicate of [didReceiveRemoteNotification method run on UI thread or separate thread](https://stackoverflow.com/q/20896993/145173). – Edward Brey Nov 30 '18 at 15:53

0 Answers0