Why do you need 2 Javascript files for cross-platform Cordova plugin?


In this <a href="http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins#CatchaboutdifferentPlatforms" rel="nofollow">article here</a>, I quote:


<strong>Catch about different Platforms</strong> Before it comes as a surprise to you, let me clarify some things. Say you are developing a Phonegap plugin for 2 platforms: iOS and Android. One might assume that we need to churn out: a single JavaScript file that will be used on both iOS and Android; one Java file for Android One .h and One .m for iOS<br /> However, in reality you will need to churn out: one Javascript file for Android, along with a Java file for Android; a different Javascript file for iOS, alone with pair of .h and .m file for iOS. Both Javascript files can (and should) have the same interface for the developer who consumes it, but the implementations of each interface would be different.


Why would you need 2 Javascript files, if the native methods are all named the same? I've created an iOS plugin (with a corresponding .js file) and now that I'm creating the Android side, I can't see why I would need a separate .js for the Android side. Any ideas why they stress this for no particular reason?


Well it depends on what version of PhoneGap/Apache Cordova you are using. In previous version the PhoneGap.exec() method signature was different between iOS and Android. As of 1.7.0 and probably as early as 1.5.0 the method signature is the same. You should be able to use the same .js file for your plugin regardless of the platform you are running on.

cordova.exec(success, fail, service, action, args);

I will create an issue to clean up the wiki instructions.


  • How to extract value from selected TextBlock element in a ListBox?
  • Hide list with one element with pure CSS
  • Create tar with same name as file but in different folder
  • Oracle: split string to rows
  • IdHttp Post Method Delphi 2010
  • Calling a jQuery method named in variable
  • Selenium 2 : finding web element locators programatically
  • How to Enable Systemd service in openshift/jenkins-1-centos7 docker container?
  • Iterating through a folder using batch script
  • Qt fresh Gui application crashes on startup, faulting at QtCore4.dll
  • hadoop jar command points to local filesystem
  • How to filter out rows from spark dataframe containing unreadable characters
  • Python C binding error
  • How to create wsdl from xsd
  • Bulk loading into PostgreSQL from a remote client
  • On unchecking a checkbox trigger an event
  • read.table returning character matrix, would like numeric
  • Dynamically run java code with Process
  • How to organize this layout with overflows?
  • How can I do case insensitive string search with Linq and SQL Server?
  • How to create OLE Automation to be used with ClearExplorer
  • Multiple canvases (pages) in Fabric.js
  • Pandas time series data Index from a string to float [duplicate]
  • AWS RDS Parameter Group not changing MySQL encoding
  • content must have a ListView whose id attribute is 'android.R.id.list'
  • How to write seo friendly url's using htaccess?
  • Create an average of multiple excel chart without the data source
  • Django, uWSGI & nginx: Process dies for “no reason”
  • using maven pom while creating jar:test-jar some times it says JAR will be empty - no content was ma
  • PHPMailer return to AJAX
  • how to run ejabberd with Erlang on Heroku?
  • How to use Streams api peek() function and make it work?
  • How to specify generic type when the type is only known at runtime?
  • Android: Unable to detect vertical plane
  • `$http:badreq Bad Request Configuration` - from angular post method, what is wrong here?
  • Bind selectedDates Aggregation for Calendar
  • Codeigniniter insert data through models and controller
  • How to call different template for different category archive page in woocommerce
  • Call Microservice from another Microservice within Docker
  • Using Service Component Runtime