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
1
vote
0 answers

Phonegab/Cordova - Launch app on GCM notification like whatsup call

I use the phonegap-plugin-push to send GCM notification on a mobile device but I'can't find anything how to start an activity when a notification is triggered. This plugin do the follow: if the activity is started and is in forderground then the…
1
vote
1 answer

Update SharePoint list item using phonegap

I could authenticate to sharepoint using azure ad and azure-activedirectory-library-for-cordova . I was able to get list from sharepoint but I could not update or create list item. This is my code to authenticate and get list. What I need is to…
user5225979
1
vote
0 answers

Unable to remove phonegap plugin via command line

I am trying to remove this "background audio" cordova/phonegap plugin from my project by using the below command, but it is failing for some reason. $ sudo phonegap plugin remove "nl.x-services.plugins.backgroundaudio" Uninstalling…
DevD
  • 1,201
  • 2
  • 12
  • 20
1
vote
1 answer

Phonegap barcode prompts to enter value

Am using phonegap-plugin-barcodescanner in a phonegap app to scan QR codes. When firing the scanner using: function scan() { cordova.plugins.barcodeScanner.scan( function (result) { alert("We got a barcode\n" + "Result: " +…
zima10101
  • 307
  • 1
  • 4
  • 16
1
vote
2 answers

Mobile app with codeigniter

I am a first year "computer programmer" college student and I got an internship where I was asked to develop a simple cross platform mobile app. Nothing too complex, consists in a login screen, then a screen with a form where I'm using jQuery UI…
1
vote
1 answer

Cordova IOS Native functionality delayed

I built an app that is working perfectly fine on Android, now I'm starting to port it for iOS and I'm facing a weird problem. The app works fine but all the native functionality that i'm using ( notifications, Photos, Video Player ) are delayed…
Dave Plug
  • 1,068
  • 1
  • 11
  • 22
1
vote
0 answers

How to use PlugIns in PhoneGap on MAC OSX? I always mess with "TypeError" & "ReferenceError:"

I am newbie in Phonegap. I did installed latest version of phoneGap app for MAC OSX. Below is version detail.MAC OSX PhoneGap App version detail :. I did cerated New PhoneGap project. Now i wants to use cordova-plugin-qrcode in my PhoneGap…
Vishal Sharma
  • 1,733
  • 2
  • 12
  • 32
1
vote
2 answers

Phonegap camera doesn't work

My Android app need to takes picture but Camera plugin doesn't work. When I click on the button nothing happens. index.html Capture Photo
1
vote
2 answers

is there a way to get scroll position directly from cordova?

I have a problem with ionic framework's native scroll. The following works fine in the browser, but not when compiled to iOS. If I poll the $ionicScrollDelegate.getScrollPosition() at an interval, I don't get up-to-date values for positions. It's…
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
1
vote
1 answer

Phonegap card reader plugin

I downloaded this plugin Magnetic Card Reader thanks to my limited experience I'm having issues. I'm using a square 3.5mm card reader the plugin according to the author is suppose to work with 3.5mm card reader. I have this code to start the card…
Millenial2020
  • 2,465
  • 9
  • 38
  • 83
1
vote
1 answer

How to configure the StatusBarOverlaysWebView phonegap plugin to prevent the status bar from overlapping the app content

I cannot get it to work. I have added the plugin to the directory via the phonegap CLI, and inserted: into config.xml in the ios platform block, but the status bar still overlays the…
Nathan
  • 246
  • 1
  • 4
  • 10
1
vote
1 answer

How to solve or bypass error websocket: origin not allowed

On my server I'm running gorilla web socket in go and I'm trying to connect from phonegap application with following javascript code: var conn = new WebSocket("ws://IP:8080/ws"); but I'm getting this error: websocket: origin not allowed on my…
iWizard
  • 6,816
  • 19
  • 67
  • 103
1
vote
1 answer

Cordova App development - adding native aar

Hi I have created an aar library(it's a android-native sdk,with it's own APIs and activities) which i need to integrate, I followed Cordova plugin development what should be the contents of Myplugin.java in src/android folder, is it mandatory to…
Ak-
  • 335
  • 4
  • 17
1
vote
0 answers

Nuance server error 500

I am implementing server side automatic speech recognition using Nuance server SDK. But none of the the sound is recognized by Nuance server. It is giving error 'Query retry 1 or 2' or 'server error 500'. I have checked my audio. Neither it is…
Amb
  • 3,343
  • 7
  • 27
  • 34
1
vote
1 answer

On installing phonegap, I am getting an error

on installing the phonegap i am getting an error npm ERR! Window_NT 6.1. 7600 npm ERR! argv " C:\\Program File(x86)\\node.js\\node.exe" "C:\\Users\\Abuzar\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "phonegap" npm…
Ather ALi
  • 9
  • 1
  • 1
  • 3
1 2 3
99
100