From 5ed731a414cc0690005629b3c535b22531354d91 Mon Sep 17 00:00:00 2001 From: Hiraku Ohno Date: Tue, 2 Oct 2018 16:07:56 +0900 Subject: [PATCH] Call methods on main thread if required --- .../RNVoipPushNotificationManager.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m b/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m index cf347e1..e9af58c 100644 --- a/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m +++ b/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m @@ -119,12 +119,14 @@ - (void)voipRegistration NSLog(@"[RNVoipPushNotificationManager] voipRegistration"); dispatch_queue_t mainQueue = dispatch_get_main_queue(); - // Create a push registry object - PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue]; - // Set the registry's delegate to AppDelegate - voipRegistry.delegate = (RNVoipPushNotificationManager *)RCTSharedApplication().delegate; - // Set the push type to VoIP - voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; + dispatch_async(mainQueue, ^{ + // Create a push registry object + PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue]; + // Set the registry's delegate to AppDelegate + voipRegistry.delegate = (RNVoipPushNotificationManager *)RCTSharedApplication().delegate; + // Set the push type to VoIP + voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; + }); } - (NSDictionary *)checkPermissions @@ -193,8 +195,10 @@ - (void)handleRemoteNotificationReceived:(NSNotification *)notification if (RCTRunningInAppExtension()) { return; } + dispatch_async(dispatch_get_main_queue(), ^{ [self registerUserNotification:permissions]; [self voipRegistration]; + }); } RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)