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:

4233 questions
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
  • 998
  • 1
  • 10
  • 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,648
  • 1
  • 11
  • 30
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
  • 9,743
  • 9
  • 66
  • 111
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
  • 1,588
  • 6
  • 22
  • 49
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
  • 216
  • 1
  • 4
  • 9
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,216
  • 16
  • 61
  • 98
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
  • 16
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,301
  • 7
  • 25
  • 33
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
vote
1 answer

can I use java code as a cordova/phonegap plugin?

I am creating a mobile app using intel xkd,angular and cordova. Here we have a java code for one module. so i wanna know, can i integrate the java code into my app like a plugin ?. Because, most of the cordava/phonegap plugin have java file as…
sibi
  • 495
  • 2
  • 6
  • 22
1
vote
0 answers

A PhoneGap Build plugin isn't present in the app's environment

I added the following to config.xml, as instructed. Restarted the server, reconnected the iOS app. I'm told the only thing left to do is to call…
dsp_099
  • 5,021
  • 13
  • 59
  • 115
1
vote
1 answer

phonegap build error with google adMob in config

my config.xml file Onsen UI Project
Shahid Karimi
  • 3,721
  • 17
  • 55
  • 94
1
vote
0 answers

AngularJS routig with jquery mobile doesn't work

I used angularjs and phonegap tools together in my application. It works great and i never face any issue while converting app into ios or apk. but when i trying to used jquery mobile within my applications it doesn't work. i read question about…
tushar balar
  • 696
  • 3
  • 8
  • 21
1 2 3
99
100