In this post, I will be sharing the differences in invoking phone dialer & mail functions using phonegap API. 


What is Phonegap?

     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

  1. Copy the .h and .m files to your project.
  2. Copy the .js file to your www folder
  3. Include the .js file with a script tag in your index.html
  4. Add "phonedialer" ----> "PhoneDialer" to your plugins mapping in config.xml
  5. 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

  1. You will need to add MessageUI.framework to your project if it is not already included.
  2. Just add the EmailComposer.h EmailComposer.m files to your Plugins Folder.
  3. Place the EmailComposer.js file in your app root, and include it from your html.
  4. Add to Cordova.plist Plugins: key EmailComposer value EmailComposer.
  5. 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+