rohfosho / CordovaCallNumberPlugin

Call a number directly from your cordova application.
MIT License
185 stars 151 forks source link

Success callback fires immediately on iOS 11 #53

Open tomjamesallen opened 6 years ago

tomjamesallen commented 6 years ago

Using window.plugins.CallNumber.callNumber(onSuccess, onFailure, number); the success callback is being called immediately on calling the method. This brings up the native call confirmation dialog, and neither of the callbacks get called on tapping Call or Cancel.

jonathanhollander commented 6 years ago

Thanks for creating this plugin but I'm having this same problem. The callback fires right away. :(

jonathanhollander commented 6 years ago

after further review of the plugins code... I believe this is actually the intended behavior... sadly. It seems the only reason the error handler would ever fire is if the system is unable to use the "tel:#####" scheme or if the phone number passed is invalid. This plugin does nothing for the detection of "Call" or "Cancel"

jonathanhollander commented 6 years ago

I post this only because maybe it'll help someone one day. So it turns out, there are some "extra" hidden events that Cordova decided to not include in its documentation (https://cordova.apache.org/docs/en/latest/cordova/events/events.html) . Specifically, there are "active" and "resign" events that will fire when your app shows a dialog like the tel:### prompt. So a combination of this plugin (https://github.com/happieio/cordova-plugin-call-hooks) with these hidden events, and knowing when your firing the "tel:#####", you should be able to determine if they pressed call or cancel.

arjel commented 6 years ago

Hello! You may use CXCallObserver from CallKit to fire the success callback when the call state is "dialing". Hope to see this soon. Thank you!