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
9
votes
1 answer

Subsequent callbacks from a Cordova iOS plugin don't fire

I have troubles with firing immediately subsequent callbacks from a cordova plugin (an iOS one). In XCode debugger I clearly see it steps over [self.commandDelegate sendPluginResult:pluginResult callbackId:monitoredRegions.callbackId]; several…
meandre
  • 2,141
  • 2
  • 16
  • 21
9
votes
1 answer

difference between window.openDatabase() and window.sqlitePlugin.openDatabase() functions?

Using Cordova version 3.x and Android version 2.x to 4.x. I am wondering: Is my understanding correct that all android devices by default have an sqlite program/interface for creating sqlite database? Do both the above database function calls…
frank
  • 3,180
  • 3
  • 16
  • 18
9
votes
4 answers

Cordova Facebook plugin : missing variables APP_ID, APP_NAME

When I do : cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git I get the error : Error: Variable(s) missing: APP_ID, APP_NAME Where do I have to configure these variables ?
Cherif
  • 5,223
  • 8
  • 33
  • 54
9
votes
2 answers

PhoneGap Build Push Notification (Android)

I am having trouble receiving any type of callback for the push notifications plugin for phonegap build, I have included the plugin inside config.xml. I have signed up to GCM and got my project number needed for pushNotification.register(). I also…
pleshy
  • 1,468
  • 2
  • 16
  • 22
9
votes
1 answer

Which are the unnecessary Phonegap plugins to remove in app?

SCENARIO I have a small Android Phonegap/Cordova 2.3.0 application, I looked into /res/xml/config.xml file and found that so many plugins are there. It is a very small app and I guess, all I am using is notifications and ChildBrowser…
shamittomar
  • 46,210
  • 12
  • 74
  • 78
9
votes
6 answers

PhoneGap Camera API for Android - Uncaught Exception

I am trying to run the Camera API using Phone gap in Android, and i am running in all sort of issues. I just copied phonegap camera example. I am getting the following error 07-12 18:18:00.706: E/Web Console(17837): Uncaught TypeError: Cannot read…
dhiku
  • 1,818
  • 2
  • 22
  • 38
8
votes
0 answers

Local Notification in Phonegap

I want to have a local notification in my iOS Phonegap app. I followed lots of tutorials and code but no help. Can anyone please guide me.
user790514
  • 137
  • 1
  • 2
  • 12
8
votes
2 answers

ngFacebook not working with phonegap

Im using ngFacebook by Almog Baku in my current angular app. In test environment it is working fine. But in apk build via phonegap it isn't working. I have included and
8
votes
6 answers

PhoneGap missing plist.key

When I try and load upload my iTunes app installer to iTunes I relieve this error: Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an …
Mike
  • 6,751
  • 23
  • 75
  • 132
8
votes
1 answer

How add android ssl certificate for https request in ionic?

In ionic simulator all http and https working fine but in real device release version its stop working. Many people adviced to add SSL certificate for release version but I dont know how to add this ? I have tries all this to make https request…
8
votes
1 answer

How to set the position of spinner with cordova

I have this in my config.xml And the spinner works great, however i need to change the position from center to something like center + 10% vertically There is any way of doing this?
user455318
  • 3,280
  • 12
  • 41
  • 66
8
votes
2 answers

Making and monitoring phone call within phonegap

I'm considering building a PhoneGap app that would work with my web app via web socket. It would receive the instruction to dial a phone number, run in the background while the phone call is in progress, detect when the phone call picks up and when…
frenchie
  • 51,731
  • 109
  • 304
  • 510
8
votes
2 answers

Get current battery level using phonegap or cordova?

Function like window.addEventListener("batterystatus", onBatteryStatus, false); function onBatteryStatus(info) { // Handle the online event console.log("Level: " + info.level + " isPlugged: " + info.isPlugged); } return battery level and…
Kamesh Jungi
  • 6,203
  • 6
  • 39
  • 50
8
votes
0 answers

Planning a cordova camera plugin with transparent overlay image

I am writing and app which needs to show a transparent image over the camera, for example as a guide for composition. The app has to be shipped at least on iOS and Android. So far, I have found a plugin with a functioning iOS source…
mico
  • 1,816
  • 1
  • 18
  • 27
8
votes
1 answer

PhoneGap: modify config.xml to add properties to Info.plist ion iOS

For my application, I need to add some settings to the Info.plist file for iOS. I thought the best way to do this, would be to add these settings to my config.xml file (I'm using PhoneGap). When I add the following to the config.xml file and…
Flock Dawson
  • 1,842
  • 4
  • 22
  • 34