Skip to content
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

"reportIncomingCall" not working inside setTimeout #10

Open
VinceOPS opened this issue May 10, 2017 · 2 comments
Open

"reportIncomingCall" not working inside setTimeout #10

VinceOPS opened this issue May 10, 2017 · 2 comments

Comments

@VinceOPS
Copy link
Contributor

VinceOPS commented May 10, 2017

Hi,

First, thanks for this plugin, it works beautifully :-).

Platform & versions
cordova 6.5
cordova-ios 4.3.1
iOS 10.2+
iPhone 5

Issue
Today I ran into my first problem: using iOS, I noticed that if I send my app to the background (simply by pushing the iphone "home" button), before an expected call to callKit.reportIncomingCall, then nothing happens when my iPhone is waiting on the iOS home screen (I'd like it to display the Incoming call screen).
I thought about the app being in 'pause' state... However, I can see my logs (console.log shown in the Safari debugger) made while the app is in the background, meaning (I guess) that my javascript code is still running...
As soon as I get back into my app, the call is immediatly reported (the CallKit screen appears, and the device vibrates).

Is there anything I did wrong here?
In the device logs, I can see the following (at the expected time, yet nothing happens):

May 10 18:06:14 iPhone-Dev MyApp(CallKit)[369] : Provider <CXXPCProvider: 0x762abf0> was asked to report a new incoming call with UUID: 130...... (etc, truncated)

I added console logging from the beginning of my process up to callKit.reportIncomingCall(). I can see all logs up to this point. Yet the call screen never shows... (until I take the app back to the foreground).

I cannot reproduce the issue on Android (everything is working perfectly).

Thanks!

@Taracque
Copy link
Owner

You need something which starts the incoming call flow. In most cases this is a Voip Push message, which wakes your app. (You can see such an ionic plugin here: https://github.com/Taracque/cordova-plugin-voippush) Otherwise you will need a Background Task on iOS to wake your app.

@VinceOPS
Copy link
Contributor Author

Hi @Taracque, thanks for your answer.

Yup, I plan to implement PushKit sooner or later, as I want my users to be able to answer a call even if the app has been paused or killed.

However, regarding my report, it seems that the fault was on the setTimeout wrapping the call of reportIncomingCall.
I was doing a dummy-testing straight code like: 1- register 2- setTimeout(reportNewCall, 2500), with a delay of 2500ms in order to make sure that the plugin has been completely registered/initialized. If register call is made earlier, and reportIncomingCall is not wrapped by setTimeout, the app behaves as expected: a call is reported, even if not in foreground.

(NB: I used a regular push notification to trigger all my sample code)

@VinceOPS VinceOPS changed the title [iOS] callKit.reportIncomingCall not working when the app is sent to background "reportIncomingCall" not working inside setTimeout May 12, 2017
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

No branches or pull requests

2 participants