1

I'll start with the environment, AppGyver Steroids (including Cordova 3.1 core plugins).

Needed functionality: make a phone call from javascript controller and detect whether the attempt succeeded or failed.

There are similar questions but they are either for Android implementation or do not address the second part of the functionality.

From what I have researched and tried, window.open('tel:12345678', '_system') is the most effective way to do this without resorting to custom plugins (preferred) but provides no way to detect if it succeeded or failed (did the dialer open or not would be sufficient).

Those types of answers brings me to the conclusion that I do need a custom Cordova plugin to get that information and that the plugin approach might even be preferred as it can access the dialer natively.

My question is 2 fold, - do you know another solution that can be implemented just with the core plugins and either returns success/fail or accepts callbacks for them? - if you're an experienced Cordova user, what would be considered best practice for this task? is there a preferred open-source plugin that works on Android and iOS? any suggestions on what the native side should look like?

Thanks

[edit] went ahead with the plugin but getting accurate information about the dialer still has issues. the generally accepted solutions seem to focus on [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]; (see this question for one discussion - unfortunately i can't comment yet). however, as others have pointed out as well, that function can fail for a whole number of reasons, some temporary, and as such, is not a reliable way to detect whether the device has an actual dialler in it. with the plugin, i can now use native but new to iOS native dev. any suggestions?

Community
  • 1
  • 1
Ozgur Susoy
  • 111
  • 9

1 Answers1

0

[answering your edit] If you just want to display/hide the call functions from devices that don't have a dialer, you could just do some browser-sniffing to test if it's and iPad/non-phone. That would generally not be a good solution, but since you are building something using Cordova on iOS you have already know what the browser is in each scenario.

probablykabari
  • 1,354
  • 10
  • 14
  • well, the solution in the edit seems to actually work quiet well for me so far but i think your solution would also work; i assume you mean something like `if(navigator.userAgent.toLowerCase().match(/ipad/))`. have seen that in a few places but as you say, its does seem a bit hacky. i would love to see better examples of natively asking the device whether it can make phone calls, preferably even picking up on things like skype or other apps that can handle making a phone call. – Ozgur Susoy Apr 24 '14 at 17:23