Questions tagged [phonegap-plugins]

A Cordova (PhoneGap) plugin bridges a bit of functionality between the WebView powering a Cordova application and the native platform the Cordova application is running on.

A Cordova (formerly PhoneGap, see ) plugin bridges a bit of functionality between the WebView powering a Cordova application and the native platform the Cordova application is running on. Plugins are composed of a single JavaScript interface used across all platforms, and native implementations following platform-specific plugin interfaces that the JavaScript will call into.

JavaScript

The entry point for any plugin is JavaScript. The reason developers use Cordova is so they can use and write JavaScript, not Objective-C, not Java, not C#. The JavaScript interface for your plugin is the front-facing and arguably most important part of your Cordova plugin.

You can structure your plugin’s JavaScript however you like. The one thing you must use to communicate between the Cordova JavaScript and native environments is the cordova.exec function. Here is an example:

cordova.exec(function(winParam) {}, function(error) {}, "service",
             "action", ["firstArgument", "secondArgument", 42, false]);

The parameters explained in more detail as follows:

  1. function(winParam) {} - Success function callback. Assuming your exec call completes successfully, this function will be invoked (optionally with any parameters you pass back to it)
  2. function(error) {} - Error function callback. If the operation does not complete successfully, this function will be invoked (optionally with an error parameter)
  3. "service" - The service name to call into on the native side. This will be mapped to a native class. More on this in the native guides below
  4. "action" - The action name to call into. This is picked up by the native class receiving the exec call, and, depending on the platform, essentially maps to a class's method. For more detail please check out the native guides located at the end of this article.
  5. [/* arguments */] - Arguments to get passed into the native environment

Native

Once you have defined a JavaScript for your plugin, you need to complement it with at least one native implementation.

For example, in , this native implementation would include doing the following:

  1. Creating a .h and .m class for the plugin
  2. Registering the class name in the Cordova.plist file
  3. Creating the function we called in the javascript as one of the instance methods of that class
  4. Handling our callback situations (if javascript expected a callback).

Further Reading

Links to learn more about the various platforms follow:

4204 questions
8
votes
3 answers

Cordova Android status Bar set to transparent

I am trying to use this plugin below to set the statusbar to transparent. But i can not achieve it, i can change it to different colours, but not transparent. https://github.com/apache/cordova-plugin-statusbar Also it works on my Android 5.0.2, but…
John
  • 983
  • 1
  • 13
  • 31
8
votes
1 answer

Phonegap/cordova Social sharing plugin , Duplicate tweet issue

I am using the social sharing plugin for sharing messages and pictures from my mobile app to facebook and twitter, The application will display a alert for "shared successfully" if the sharing is success and will display "sharing cancelled" if the…
8
votes
2 answers

Speed is “null” with geolocation plugin on Android 5+

speed value is always null in Android 5+. We use these: Core: Cordova - 5.1.1 Platform: Cordova-Android 4.0.2 Plugin version: 1.0.1 Devices: Samsung Galaxy S4 (A5.0.1), Nexus 5 (A5.1.1), LG G3 Stylus D690 (A5.0.2). We get this problem now after we…
8
votes
1 answer

How to use PhoneGap with Facebook login and Passport.js

I struggle to find a full example of PhoneGap app using Facebook login that integrates nicely with passport.js. If seems like the PhoneGap FB plugin is returning AccessToken while passport FB plugin expect to work with code and then replace it with…
Guy Korland
  • 9,139
  • 14
  • 59
  • 106
8
votes
2 answers

Facebook app settings on PhoneGap application

I have a phonegap application that uses the main facebook-plugin for connecting. I'm also using the phonegap build to directly get the apk/ipa without generating an android/ios project. Inside the facebook for developers, however, I have to complete…
Radu Vlad
  • 1,474
  • 2
  • 21
  • 37
8
votes
3 answers

Cordova plugin.xml add "Header Search Paths" entry

I would like a new entry to be added under "Header Search Paths" once my Cordova plugin is added to an Xcode project. How can I config it in my Cordova plugin.xml file? Thanks.
Alon Amir
  • 4,913
  • 9
  • 47
  • 86
8
votes
1 answer

Phonegap detect if the phone is active

I've been searching for a while now, and can't find anything for this with Phonegap only for Android or IOS. So would be nice if someone knew how or if its even possible. Is there a way to check if the phone is in use/active, or if the phone is…
Marius Djerv
  • 267
  • 1
  • 4
  • 18
8
votes
3 answers

Adding Cordova/Phonegap plugins behind a proxy

I've successfully installed Cordova (clean install, under Windows), and I'm able to deploy a small app to Android, but unable to add any plugins behind my company's proxy. I've already tried setting every possible npm and git variable I could think…
white_pawn
  • 205
  • 1
  • 4
  • 10
8
votes
2 answers

How to display Splashscreen in Phonegap 3.3

How to display the splashscreen correctly? I'm using CLi local build and I heared it's compatible. I added the plugin with: phonegap plugin add org.apache.cordova.splashscreen And this is my config file:
Alex Stanese
  • 735
  • 4
  • 16
  • 33
8
votes
2 answers

Phonegap Plugin - append lines to app delegate

I'm developing a phonegap plugin. So far so good. Now I would like to append 1 or 2 methods to the AppDelegate.m through the config.xml so it will be populated for the developer automatically. Is it possible? Thanks.
Asaf
  • 2,158
  • 2
  • 25
  • 40
8
votes
2 answers

PhoneGap Bluetooth Plugin on Android device

I've been trying to get a bluetooth plugin for PhoneGap working but I can't seem to figure out where I'm going wrong. Firstly, my test device is a Galaxy S3 (GT-19305T) and the applications were built using the PhoneGap CLI. The plugin I am…
benallansmith
  • 816
  • 3
  • 10
  • 26
8
votes
2 answers

How to Add a Third Party Framework to a Cordova 3.0 Custom Plugin?

I'm trying to create a cordova plugin with a third party framework (in this case AdColony.framework) https://github.com/AdColony/AdColony-iOS-SDK. I'm having trouble figuring out how to add this framework using the plugin.xml (Plugin…
sharic19
  • 1,139
  • 3
  • 15
  • 25
8
votes
2 answers

Android/PhoneGap: Using third-party libraries in plugin-development

I'm working on a PhoneGap/Cordova plugin that's supposed to provide a socket for sending and receiving OSC messages (Open Sound Control). For that purpose I'd like to use JavaOSC but I'm uncertain about how to include the library into my…
5tefan
  • 243
  • 2
  • 5
  • 13
8
votes
2 answers

Phonegap File Transfer of picture fails on every other picture: Error code 3 with FileTransfer upload

I answered this question myself since it took me a long time to find the solution for it and it wasn't documented very well.
Varun Nath
  • 5,570
  • 3
  • 23
  • 39
8
votes
3 answers

PhoneGap Email Plugin

I am trying to use the plugin here This is the first time I have started to use Phonegap in Android, so the process is a little unfamiliar to me. So far I have added the .JAVA file to here "src.org.apache.cordova" I have added the .JS to the www…
user1124378