Question

Regarding the coding of plugins for PhoneGap, the PhoneGap wiki says:

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

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.

My question is: Why should I need 2 Javascript files, for each platform one? This is how the Javascript part of a plugin looks like:

var FilePlugin = function() {};
FilePlugin.prototype.read = function(data, successCallback, failureCallback) {
return PhoneGap.exec(    
        successCallback,   
        failureCallback,    
        'FilePlugin',  
        'read',              
        [data]);       
};
PhoneGap.addConstructor(function() {
PhoneGap.addPlugin("FilePlugin", new FilePlugin());
});

I cannot see something platform-dependent there, so why does the wiki say I need an own Javascript file for each platform?

Probably I got this wrong, so I need your help ;)

Thanks

Was it helpful?

Solution

I think the exec API was different but they are working on making it the same, was a while since I did any PhoneGap development. And if you look at the individual pages about plugin development for iOS and Android about PhoneGap.exec they look the same. Also note that the text on the wiki you are referring to seems to a nearly on year old.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top