-
Notifications
You must be signed in to change notification settings - Fork 150
feat: configureCallKit before JS initialisation to avoid dropping incoming calls on cold start #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
vuletuanbt
commented
Mar 12, 2021
|
Thank you for your PR @vuletuanbt, we will review it as soon as possible! @fabriziomoscon For review |
|
@vuletuanbt I will test this tonight |
|
@vuletuanbt I will continue testing this today, as last night I run into Signing certificates issues |
|
UPDATE: |
|
UPDATE: |
|
@fabriziomoscon @vuletuanbt |
|
UPDATE: |
| } | ||
|
|
||
| - (void) reRegisterWithTwilioVoice { | ||
| NSString *accessToken = [self fetchAccessToken]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code has been copied and pasted form the function:
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
Please extract the code into a function so that it can be called in both occasions
|
@vuletuanbt please could you let me know which pod |
|
|
@vuletuan after reading these: When receiving a background call, there could be a race condition between the native handling of the push and the JS initialisation: To fix this issue this PR should suggest to perform as much of the CallKit initialisation as possible in the main app. |
So, you mean I could use an event to communicate with JS instead of the directed way like I did to handle the incoming call |
|
No, I will integrate the necessary changes into #164 |
|
@vuletuanbt I have added this commit on top of the new branch: c176602 But it doesn't work for me, because the to register for CallKit you need the accessToken which is provided by the server, which is contacted by JS, where the user session credentials are stored. I see this errors in the Xcode debug log: ERROR:Twilio:[Platform](0x102d46bc0): Registration failed: Error Domain=com.twilio.voice.error Code=31301 "Registration failed" UserInfo={NSLocalizedDescription=Registration failed, NSLocalizedFailureReason=Invalid Access Token}
2021-04-07 00:12:39.225224+0100 Hoxfon[336:12211] ERROR:Twilio:[Platform](0x102d46bc0): Inside register:deviceToken:completion:, failed to register for Twilio push notifications. Error:Registration failed
2021-04-07 00:12:39.227025+0100 Hoxfon[336:12211] An error occurred while registering: Registration failed
2021-04-07 00:12:39.228 [warn][tid:main][RCTEventEmitter.m:53] Sending `deviceNotReady` with no listeners registeredAre you and @reikireirikei experiencing the same issue? How did you make it work? |
I ran into it the first time launch app but it's ok. After that, you just init Twilio on JS like before. Then you can receive the call normally. Maybe it needs some enhance |
|
I see. I have checked the Twilio quickstart project and I can see that it has a few important changes, so I think it is best for me to focus on migrating this module to align with the latest Twilio SDK version before reconsidering this PR. I hope that you would agree with me that having errors at initialisations is not what we want. Feel free to use your own fork until then |
Sorry for my bad. I was missing to resolve this. I just focused to handle the incoming call in the background.
Is that your master or Twilio ? Can you share with me?
Is that the 5.5.2 version on IOS ? |
|
I will leave my experiment that uses your code here: https://github.com/hoxfon/react-native-twilio-programmable-voice/commits/feat/twilio-android-sdk-5-and-ios-bg-call-exp just in case you need to confirm the errors or try to fix it. Background calls on iOS work on the current Twilio changelog is here: https://www.twilio.com/docs/voice/voip-sdk/ios/changelog My Apps file: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"Hoxfon"
initialProperties:nil];
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
for (NSString *imgName in allPngImageNames){
if ([imgName containsString:@"LaunchImage"]){
UIImage *img = [UIImage imageNamed:imgName];
if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
rootView.backgroundColor = [UIColor colorWithPatternImage:img];
}
}
}
NSLog(@"Twilio Voice Version: %@", [TwilioVoice sdkVersion]);
return YES;
}If you want to help with this project please be my guest. And I would really like if you could help with commits on branch
Thank you for your help! |