Skip to content

support store completion for invoke later #52

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

Merged
merged 2 commits into from
Apr 30, 2020

Conversation

zxcpoiu
Copy link
Member

@zxcpoiu zxcpoiu commented Mar 25, 2020

Motivation

From iOS 11+, we should use

(void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion

Apple asked us to call completion() when we've done the job.

I've observed that if we call completion() directly after reportCallkit on the native side in the same block of didReceiveIncomingPushWithPayload, since react native initialized asynchronously and we might have some works to do on the JS side to initiate a call, in this case, if we call completion() too early, it may cause our js job to stop executing. ( The system revoke the execution lock when we call completion() I guess. And seems different iOS version acts differently when call completion())

This may be useful to someone.

Usage:

d519bee

@zxcpoiu
Copy link
Member Author

zxcpoiu commented Mar 25, 2020

I'll leave it here for few days/weeks for feedback.

@vinayr
Copy link

vinayr commented Apr 7, 2020

Please merge this. Without this, it's a hit or miss. With this, JS bridge works 100% of the time. Tested on iPhone 6 (iOS 12.4.5)

@tsugitta
Copy link

tsugitta commented Apr 8, 2020

by using this, is it possible to call reportNewIncomingCall from JS layer and then call completion() ?

@zxcpoiu zxcpoiu force-pushed the completion_handlers branch from d519bee to 977cd28 Compare April 30, 2020 08:42
@zxcpoiu zxcpoiu merged commit 9455386 into react-native-webrtc:master Apr 30, 2020
@zxcpoiu
Copy link
Member Author

zxcpoiu commented Apr 30, 2020

@tsugitta

No, I don't think so. Apple says should invoke reportNewIncomingCall ASAP and in the same block of the function. We might have successfully to call reportNewIncomingCall on the js side, but it's risky, because no one knows what is the algorithm behind the scene of current ios version that determine when to kill your app.

@dariomalfatti-centropaghe

When I call reportNewIncomingCall passing the completion handler to withCompletionHandler property, on js side, have I to call VoipPushNotification.onVoipNotificationCompleted(notification.uuid); to let iOS know that it's finished?
Right after calling the reportNewIncomingCall method on the native site, my phone starts ringing but I'm still doing some jobs on js side, like registration. It's that right? I thought that only after I would call the completion method, It would starts the call flow. Thank you in advance if someone can clarify the logic behind it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants