Skip to content

Commit 617bfa3

Browse files
hirazxcpoiu
authored andcommitted
Call methods on main thread if required (#22)
1 parent cf32233 commit 617bfa3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ios/RNVoipPushNotification/RNVoipPushNotificationManager.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ - (void)voipRegistration
119119
NSLog(@"[RNVoipPushNotificationManager] voipRegistration");
120120

121121
dispatch_queue_t mainQueue = dispatch_get_main_queue();
122-
// Create a push registry object
123-
PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
124-
// Set the registry's delegate to AppDelegate
125-
voipRegistry.delegate = (RNVoipPushNotificationManager *)RCTSharedApplication().delegate;
126-
// Set the push type to VoIP
127-
voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
122+
dispatch_async(mainQueue, ^{
123+
// Create a push registry object
124+
PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
125+
// Set the registry's delegate to AppDelegate
126+
voipRegistry.delegate = (RNVoipPushNotificationManager *)RCTSharedApplication().delegate;
127+
// Set the push type to VoIP
128+
voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
129+
});
128130
}
129131

130132
- (NSDictionary *)checkPermissions
@@ -193,8 +195,10 @@ - (void)handleRemoteNotificationReceived:(NSNotification *)notification
193195
if (RCTRunningInAppExtension()) {
194196
return;
195197
}
198+
dispatch_async(dispatch_get_main_queue(), ^{
196199
[self registerUserNotification:permissions];
197200
[self voipRegistration];
201+
});
198202
}
199203

200204
RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)

0 commit comments

Comments
 (0)