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

How to integrate/use `WKWebView` plugin in PhoneGap application

I have a Phonegap iOS application in which I am using Angular Kendo mobile framework for build UI. I want to use WKWebView in my application instead of UIWebView. So what all steps I need to follow to do so? I tried to integrate it by adding the…
User7723337
  • 11,025
  • 23
  • 85
  • 147
1
vote
2 answers

Cordova InAppBrowser slower when hidden

I noticed that when using Cordova InAppBrowser to load a page it takes much more to load when it's set to hidden=yes. What's happening? Slow: ref = cordova.InAppBrowser.open(url, '_blank', 'location=yes,hidden=yes,clearsessioncache=yes'); Fast: ref…
1
vote
1 answer

How to get Push Notifications of iPhone App on Apple Watch using cordova without apple watch App?

I am developing an iPhone Mobile App using Cordova, For that I have integrated push notification plugin, I am receiving successfully push notification in my iOS devices. I want to show same notification with Apple Watch. So my question is How does…
Ketan
  • 36
  • 1
  • 4
1
vote
1 answer

Issue in older android versions with branch.io in Cordova

I am trying to use Branch in my Cordova Android app. Everything works fine in android versions above 4.4.2 But, in all versions below android 4.4.4 , Branch does not work. I have done function onDeviceReady() { console.log(Branch); …
programmer
  • 304
  • 8
  • 22
1
vote
1 answer

What is the path in hybrid app for files inside the www folder(local folder)?

What is the path in hybrid apps for android,windows and ipad for files stored inside project solution as www->data->filename.doc? I want to access these files and open them.
1
vote
0 answers

Cordova Media 2.1.0 - Audio background screen lock not working xcode 7 AVPlayer

I'm developing an audio app using phonegap 6, cordova media plugin 2.1.0 and xcode 7 and testing in one ipad with ios 8.3 and another one ios 9.0. Everything works fine when the app is in background without the screen locked but when I lock the…
1
vote
2 answers

Ionic android and ios CSS issue

I am facing a problem of CSS in ionic application in android. The problem is that CSS is not working in Android phone. For example) When I execute in Samsung Galaxy S5, the css is working correctly(See Screenshot 1). But when I execute Samsung…
Tim Rogers
  • 123
  • 2
  • 12
1
vote
1 answer

CORS header 'Access-Control-Allow-Origin' missing Cordova

I'm creatring a cordova-appache application where I communicate with a web server (get and post http request to http://192.168.1.1/cgi/json/****) in my code javascript I'm using xhr , when I send the first get request, the server respond me with…
mntsr
  • 31
  • 4
1
vote
3 answers

Display pdf in phonegap App

How can I display online PDF in My Phonegap App. I am trying iframe but PDF is not display any other solution? I want to display PDF from URL in my App not display in default PDF viewer. Thanks in advance
Krishna
  • 793
  • 1
  • 9
  • 23
1
vote
0 answers

How to open multipage XLS sheet in PhoneGap iOS App

How can I open multipage XLS sheet in PhoneGap iOS App? One method is by using in-app browser: cordova.InAppBrowser.open('yourFileUrl', '_blank'); But by using this method, it opens single page excel sheet; but, for multi-page XLS files, it shows…
Ashutosh
  • 11
  • 1
1
vote
1 answer

{{x.date | date:'hh:mm'}} is not working

Am getting date from json data as Apr 15, 2015 10:15 PM I want to display time only from json response data like 10:15 PM in html page Here i put my js function and html code JS Function function smsHistory($scope) { var user_id =…
1
vote
0 answers

How to fetch only those Contacts having photo using Cordova Plugin Contacts?

Using options.filter working well for displayName, name, emails, phoneNumbers etc and returns only matched contacts, but it is not working for photos and retuning unmatched contacts too as I want to fetch only those contacts having photos.…
shubh jaiswal
  • 337
  • 1
  • 5
  • 18
1
vote
0 answers

My phonegap app was rejected after uploading it to Google Play

When I have make a APK file using buildPhonegap App and upload on Google player Store It will Give me error: We rejected APPNAME, with package name com.mindcrew.APPNAME, for violating our Malicious Behavior policy. If you submitted an update, …
1
vote
0 answers

Jpush: receiving push notifications in background in Android 6.0

I am using the Jpush plugin for Phonegap (https://github.com/jpush/jpush-phonegap-plugin) in order to receive push notifications. This works well till few minutes after that my app is put in background. I need to reopen my app to be able to receive…
1
vote
0 answers

Play audio file in PhoneGap(react)

I have a problem with react. When I am trying to read audio file in Phonegap android apk file I am always getting the problem: E/MediaResourceGetter: Unable to read file: file:///android_asset/www/185cee6241898184ab5373e74bcd4499.mp3 E/MediaPlayer:…
Erick Voodoo
  • 315
  • 3
  • 11
1 2 3
99
100