i want to develop a hybrid application which makes a phone call to a static number automatically when clicking on a button using mobilefirst.can you help me?
1 Answers
It's not specific to IBM MobileFirst. A bit of googling would've given you the answer you needed...
Here are a couple of options to open the dialer with a number:
- Directly in the HTML (you can style the
a
to look like a 'button'):<a href="tel:+1-800-555-1234">call this number</a>
- Using JavaScript code to be called in a function:
document.location.href = "tel:+375292771265";
Edit:
It seems that you want to auto-dial.
iOS: In iOS this is not allowed in webpages. Worklight apps are essentially web code and thus considered a "webpage" by the OS and will thus first display an alert confirming if the end-user truly wants to call this number or not. In a native app the dialer will auto-dial. This can be read in the iOS documentation: https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html
Android: not allowed by the OS. You may be able to achieve this using a Cordova plug-in: see how to create Cordova plug-ins in MobileFirst Platform Foundation and a possible functionality implementation.
-
I tried the code below :it gives me number to call on the dialer screen but it doesn't make the call automatically – Wejden Tazarki Jul 25 '15 at 15:30
-
You did not specify which platform (iOS, Android, ...) are you attempting this on. In iOS for example this is not allowed in webpages. A web app, essentially runs web code and thus is considered a "webpage" by the OS and will thus first display an alert confirming if the end-user truly wants to call this number or not. In a native app the dialer will auto-dial. This can be read in the iOS documentation: https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html – Idan Adar Jul 25 '15 at 15:37
-
I tried to run this code on android platform, and it didn't work. Should i develop the functionality in a native way? – Wejden Tazarki Jul 25 '15 at 16:17
-
This is not possible for web apps. You may need to implement a Cordova plug-in to accomplish auto dialing for Android: http://stackoverflow.com/questions/13233091/call-predefined-number-automatically-on-android-with-phonegap – Idan Adar Jul 25 '15 at 16:22