In this post, I will be sharing the differences in invoking phone dialer & mail functions using phonegap API.
It enables software programmers to build applications for mobile devices using JavaScript, HTML5 and CSS3, instead of lower-level languages such as Objective-C/core-java. The resulting applications are hybrid, meaning that they are neither truly native (all layout rendering is done via the webview instead of the platform's native UI framework) nor purely web based (they are not just web apps but packed for appstore distribution, and have access to part of the device application programming interface).
For now, I will be sharing only about Phone-dialer and Emailcomposer api. Before making those api calls in IOS, you need play around with xcode to make it work i.e., copy certain files to project, details below. Whereas, in case of Android, it just invoking a simple dom function. Also, You will have to invoke the API using onclick/tap/touch listener over respective javascript libraries.
PhoneDialer API:
IOS
- Copy the .h and .m files to your project.
- Copy the .js file to your www folder
- Include the .js file with a script tag in your index.html
- Add "phonedialer" ----> "PhoneDialer" to your plugins mapping in config.xml
- Once done, wrap this function in tap/touch listener.
window.plugins.phoneDialer.dial('12-345-6789');
Android
Simple, Just wrap this function in tap/touch listener.
document.location.href ='tel: + 12-345-6789';
Email Composer API:
IOS
- You will need to add MessageUI.framework to your project if it is not already included.
- Just add the EmailComposer.h EmailComposer.m files to your Plugins Folder.
- Place the EmailComposer.js file in your app root, and include it from your html.
- Add to Cordova.plist Plugins: key EmailComposer value EmailComposer.
- Once done, wrap this function in tap/touch listener.
window.plugins.emailComposer.showEmailComposer("","", "john.doe@example.com", "", "",false);
Android
Simple, Just wrap this function in tap/touch listener.
document.location.href ='mailto:john.doe@example.com';
Have fun!!! B-) Google+