Code Monkey home page Code Monkey logo

ng-cordova's Introduction

This library is obsolete

ngCordova is obsolete and is no longer maintained.

Please move to our new native plugin library, Ionic Native. See this issue for more information: #1452

ngCordova

Travis Bower

Cordova with AngularJS Goodness

ngCordova Logo

ngCordova gives you simple AngularJS wrappers for a massive amount of Cordova plugins. Check out the list below for all of the available plugins, and create an issue for a new request.

Created by the Ionic Framework team and the community.

RESOURCE LINK
Website ngCordova.com
Docs ngCordova.com/docs
Requirements AngularJS, Cordova
Install bower install ngCordova or download zip file
Custom build ngCordova.com/build

Installation

Install manually, or from bower:

$ bower install ngCordova

Plugins (67+)

* official Apache Cordova Plugin

Authors

Max Lynch

Paolo Bernasconi

Project Maintainer

George Stocker

LICENSE

ngCordova is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.

ng-cordova's People

Contributors

andwaal avatar beauby avatar bitsmuggler avatar brunogonncalves avatar davidepastore avatar evanliomain avatar fraserxu avatar gortok avatar jonlil avatar justinnoel avatar khashayar avatar ladas-larry avatar langstra avatar loiane avatar mike-roberts avatar mlynch avatar mzbyszynski avatar nraboy avatar paldom avatar patrickjs avatar pbakondy avatar pbernasconi avatar pellekrogholt avatar programming-kid avatar romgar avatar saimon24 avatar sidneys avatar sunsus avatar tomasbedrich avatar tomayoola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-cordova's Issues

Add Github Link on pages

Looks great! Only problem was I couldn't find the Github link on the pages site. Maybe add a fork dash or just a link to the gh repo?

Determine device type for plugins

Many plugins have different requirements and parameters for different device types.

e.g. the Social Sharing Plugin has very different requirements for Android than for iPhone.

It would be nice to determine what device the user is using, and then conditionally apply different requirements in the backend so that the ngCordova API is standard across all platforms.

More Plugins to Add

Properties:

  • connection.type

Constants:

  • Connection.UNKNOWN
  • Connection.ETHERNET
  • Connection.WIFI
  • Connection.CELL_2G
  • Connection.CELL_3G
  • Connection.CELL_4G
  • Connection.CELL
  • Connection.NONE

Maybe include a promise for isOnline() / isOffline()


Parameters:

  • device.cordova
  • device.model
  • device.name
  • device.platform
  • device.uuid
  • device.version

adds the following three window events:

  • batterystatus
  • batterycritical
  • batterylow

Methods

  • contacts.create(contact)
  • contacts.find(success, error, fields, options)
  • contacts.pickContact(success, error)

Objects

  • Contact
  • ContactName
  • ContactField
  • ContactAddress
  • ContactOrganization
  • ContactFindOptions
  • ContactError
  • ContactFieldType



Methods:

  • StatusBar.overlaysWebView(boolean)
  • StatusBar.styleDefault()
  • StatusBar.styleLightContent()
  • StatusBar.styleBlackTranslucent()
  • StatusBar.styleBlackOpaque()
  • StatusBar.backgroundColorByName(color)
  • StatusBar.backgroundColorByHexString(hex)
  • StatusBar.hide()
  • StatusBar.show()

Parameters:

  • StatusBar.isVisible

Methods:

  • BarcodeScanner.scan(success, fail)
  • BarcodeScanner.encode(type, data, success, fail)


Methods:

  • splashscreen.show()
  • splashscreen.hide()


Methods:

  • Keyboard.hideKeyboardAccessoryBar
  • Keyboard.close
  • Keyboard.disableScroll

Properties

  • Keyboard.isVisible

Events

  • native.keyboardshow
  • native.keyboardhide

$cordovaDeviceMotion.watchAcceleration doc is incorrect on ngcordova.com

The example for $cordovaDeviceMotion.watchAcceleration in http://ngcordova.com/docs/ is incorrect.

$cordovaDeviceMotion.watchAcceleration({
  }, function() {/* unused */},
  }, function(err) {
    /* errors */
  }, function(result) {
    /* the result is notified here when it changes */
  });

There was extract bracket & missing then(). It should should be:

$cordovaDeviceMotion.watchAcceleration({ frequency: 5000 }).then(
function() {/* unused */},  
function(err) {},
function(acceleration) {
  $cordovaDialogs.alert('Acceleration X: ' + acceleration.x + '\n' +
        'Acceleration Y: ' + acceleration.y + '\n' +
        'Acceleration Z: ' + acceleration.z + '\n' +
        'Timestamp: '      + acceleration.timestamp + '\n');
});

Bug in $cordovaDeviceMotion - getCurrentAcceleration

There should be no third param options for navigator.accelerometer.getCurrentAcceleration in this file:

https://github.com/driftyco/ng-cordova/blob/master/src/plugins/deviceMotion.js#L14

Ref: http://cordova.apache.org/docs/en/2.5.0/cordova_accelerometer_accelerometer.md.html#accelerometer.getCurrentAcceleration

Replace with this instead:

      navigator.accelerometer.getCurrentAcceleration(function(result) {
        // Do any magic you need
        q.resolve(result);
      }, function(err) {
        q.reject(err);
      });

Uncaught ReferenceError: device is not defined

tl;dr: would you mind adding an enabled method/flag to each module?

Use Case:
I run my apps using ripple (directly in my desktop browser) while developing, so plugins are typically unavailable. Let's say I want to log device information on startup (e.g, $log.log($cordovaDevice.getDevice())), I would get a ReferenceError in the browser (device is not defined).

I would like to do a quick check that the plugin is enabled. something like:

$log.log($cordovaDevice.enabled() ? $cordovaDevice.getDevice() : "device n/a");

Thanks for this! (and ionic!)


alternatively, could you return window.device from getDevice() for the times when device is not defined?

Feature Request: Add clipboard plugin

First a big THANK YOU for the great idea!

I would appreciate it if you would add com.verso.cordova.clipboard since using the clipboard is some essential functionality as well.

Thanks for considering it!

Custom Build System

From the conversation on twitter: https://twitter.com/andrewmcgivery/status/473908852514385920

Idea Description
A custom build system to only include the cordova-wrapped modules you need. Check off the plugins you want wrapped, click build, and you are served a custom-built script.

Why?
Having one giant file with every possible plugin wrapped doesn't seem scalable. Now there are only 14 plugins, but what about down the road when there are 50? 100? If I only want to use one Cordova plugin, I don't want to pull in 13 other wrappers (or 99 in my worse case scenario).

Demo/Prototype
http://www.ngcordova.mcgivery.com/

Additional Notes
This method could turn out to be very cool and useful if you have a searchable list (say, with hundreds of items) of plugins and the ability to check off the ones you want and then build the custom script.

fallback to browser alert or prompt when navigator.notification is not there?

Hi there, great module here!

Our team is working on a project using ionic, and we also doing the same thing in our code as here. But we didn't make it a module like u did.

In our service code for the notification for example, we will check whether the navigator.notification is undefined, if it's there just use it, but if not, then fallback to use the default element from browser.

This is helpful when you debug or code and test from the browser instead of running emulator every time you change the code.

alert: function(message, callback, title, buttonName) {
    if(navigator.notification) {
        return navigator.notification.alert.apply(navigator.notification, arguments);
    } else {
        window.alert.apply(navigator.notification, arguments);
    }
}

If you need it I can send a pull request. :D

$cordovaPush : Cannot read property 'pushNotification' of undefined

Hello,
I'm try to use ngCordova for notifications. I get the following error :
TypeError: Cannot read property 'pushNotification' of undefined
at Object.register (http://localhost/mobile/www/lib/ngCordova/dist/ng-cordova.js:827:27") => window.plugins.pushNotification

Below is my controller :

//test Push Notification cordova
.controller('PushCtrl', function($scope, $cordovaPush) {
var androidConfig = {
"senderId": "MySenderId"
"ecb": "onNotification"
};

console.log('DEBUG CORDOVA PUSH ',$cordovaPush);

$cordovaPush.register(androidConfig).then(function(result) {
        //success
        console.log('DEBUG  ', result);
    }, function(err) {
        console.log('DEBUG  ', err);
    }

)

function onNotification(e) {
    $("#app-status-ul").append('<li>EVENT -> RECEIVED:' + e.event + '</li>');

    switch (e.event) {
        case 'registered':
            if (e.regid.length > 0) {
                $("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
                // Your GCM push server needs to know the regID before it can push to this device
                // here is where you might want to send it the regID for later use.
                console.log("regID = " + e.regid);
            }
            break;

        case 'message':
            // if this flag is set, this notification happened while we were in the foreground.
            // you might want to play a sound to get the user's attention, throw up a dialog, etc.
            if (e.foreground) {
                $("#app-status-ul").append('<li>--INLINE NOTIFICATION--' + '</li>');

                // on Android soundname is outside the payload. 
                // On Amazon FireOS all custom attributes are contained within payload
                var soundfile = e.soundname || e.payload.sound;
                // if the notification contains a soundname, play it.
                var my_media = new Media("/android_asset/www/" + soundfile);
                my_media.play();
            } else { // otherwise we were launched because the user touched a notification in the notification tray.
                if (e.coldstart) {
                    $("#app-status-ul").append('<li>--COLDSTART NOTIFICATION--' + '</li>');
                } else {
                    $("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
                }
            }

            $("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.payload.message + '</li>');
            //Only works for GCM
            $("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');
            //Only works on Amazon Fire OS
            $status.append('<li>MESSAGE -> TIME: ' + e.payload.timeStamp + '</li>');
            break;

        case 'error':
            $("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>');
            break;

        default:
            $("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');
            break;
    }



}

});

Thank you in advance.
Kristi.

Add QR code scanner too

I have been developing apps using Ionic and Cordova a lot. It would be really helpful if you add a QR code scanner plugin too in ngCordova.

Thanks.

Update READ.ME - Is Ionic required?

The docs are confusing as read like the Ionic framework isn't required but from the quick POC I ran the promises returned by ngCordova never resolve. This happens whether or not I include cordova.js.

Smooth out Geolocation plugin to avoid permission popup

Even with the geolocation popup, it's still possible to trigger the ugly WebView permission dialog for geolocation instead of the native one the popup will trigger.

Someone reported injecting a simulated delay or forced button click before a call to getCurrentPosition which would properly avoid the ugly permission popup.

$cordovaNetwork is not working

$cordovaNetwork is not working. When I did "alert(JSON.stringify($cordovaNetwork));", It is returning "{}" in ios. Not tested in android though.

Note in doc to include ng-cordova.js before cordova.js

In .html file, make sure to put ng-cordova.js before cordova.js

<script src="lib/ionic/js/ng-cordova.js"></script>
<script src="cordova.js"></script>

If the other way around, I found out the rubber scrolling effect disappeared in ionic list. Not testing completely yet but I don't know why either.

May as well make that as a note in the docs.

web dev strategy

Hey
Very cool initiative guys, thanks :)

Do you plan to offer a solution to override the cordova calls while not in cordova context ?
For example, while developing in chrome it would be cool to have a standard way to provide mocks, for example for the ContactApi.

I'd be pleased to help :)

Device UUID

More of a question than an issue for now :)

The device plugin's uuid attribute : How reliable is it to use as a unique identifier for users of my application?

Adding $cordova prefix

I was thinking of prefixing all services with $cordova, so the camera one would be $cordovaCamera

Thoughts?

Link between ngCordova plugin and plugin repo

Hi guys,

When using ngCordova and one of the implementations in src/plugins, a developer should easily be able to figure out which plugin he actually needs to integrate. For example this wrapper code https://github.com/driftyco/ng-cordova/blob/master/src/plugins/socialSharing.js should be used with this plugin https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.

Also the other way around: as a plugin developer I'm considering linking to your project, but if I want to provide a deeplink to specific file in src/plugins, I need to be sure your Angular wrapper was based on my plugin.

As a developer I expect the plugin repo to be mentioned in the docs, or at least as the first comment in the wrapper js file.

Thanks,
Eddy

Using $ionicPlatform.ready() in module.js before plugins are initialized

What do you think about returning a promise in the module which uses $ionicPlatform.ready() to make sure the plugins are not used until the dom is ready?

angular.module('ngCordova', [ngCordova.plugins])
  .factory('ngCordova', function ($q, $rootScope, $ionicPlatform) {
    var deferred = $q.defer();

    $ionicPlatform.ready(function () {
      console.log('ionic is ready');
      $rootScope.$apply(deferred.resolve);
    });

    return {
      ready: function () {
        return deferred.promise;
      }
    };
  })
  .run(function (ngCordova) {});

Then each plugin uses the ngCordova service service like so:

.factory('Notification', function ($q, ngCordova) {
  return {
    alert: function (message, alertCallback, title, buttonName) {              
       ngCordova.ready().then(function () {
          navigator.notification.alert(message, alertCallback, title, buttonName);
       });
    }
  };
});

$cordovaFile.checkFile no work on android 4.3

Trying the "checkfile" cordova gave me an exception. To resolve this I had to modify the following function '$ corodvaFile' by removing the backslash.

java.lang.NullPointerException
at org.apache.cordova.file.LocalFilesystem.filesystemPathForURL(LocalFilesystem.java:73)
at org.apache.cordova.file.LocalFilesystem.getFileForLocalURL(LocalFilesystem.java:182)
at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:759)
at org.apache.cordova.file.FileUtils.access$600(FileUtils.java:52)
at org.apache.cordova.file.FileUtils$17.run(FileUtils.java:405)
at org.apache.cordova.file.FileUtils$24.run(FileUtils.java:533)

Workaround
checkFile: function (dir, file) {
        var q = $q.defer();

        getFilesystem().then(
          function (filesystem) {
            filesystem.root.getFile(dir + '/' + file, {create: false},
              // File exists
              function () {
                q.resolve();
              },
              // File doesn't exist
              function () {
                q.reject();
              }
            );
          }
        );

        return q.promise;
      }

$cordovaGeolocation.clearWatch cannot be called

$cordovaGeolocation does not provide a way to get the watchId returned by the call to navigator.geolocation.watchPosition (in fact it seems to discard it altogether).

Without this watchId, I cannot call clearWatch. And clearWatch is important because watchPosition will drain the battery if left running.

Add the JS files to main web site

Ok, it is a minor thing, but it bugs me that I have to come to github to grab ngcordova.js. Why not include a copy (or even a link to the raw copy on GH) on the main marketing site?

$cordovaNetwork: TypeError: Cannot read property 'type' of undefined

hi,

i'm using current master (7980897) of ng-cordova and like to use $cordovaNetwork in a login controller for example:

var loginControllers = angular.module('loginControllers', []);

loginControllers
  .controller('LoginCtrl', [
'$scope',
'$log',
'$state',
'$ionicLoading',
'$cordovaNetwork',
function($scope, $log, $state, $ionicLoading, $cordovaNetwork) {

  var type = $cordovaNetwork.getNetwork();
  var isOnline = $cordovaNetwork.isOnline();

  $log.log('network type', type);
  $log.log('network isOnline', isOnline);

  $ionicLoading.show({
    template: '... loading ...'
  });

}]);

when i deploy to an android (4.4) nexus 4 device i get a blank screen.

then with chrome://inspect device - i get the following in the console:

TypeError: Cannot read property 'type' of undefined
at Object.getNetwork (file:///android_asset/www/lib/ng-cordova/dist/ng-cordova.js:793:34)
at new <anonymous> (file:///android_asset/www/js/login/controllers.js:27:66)
at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12641:17)
at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12652:23)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:15711:28
at updateView (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:41075:30)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:41031:9
at nodeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:15161:13)
at compositeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:14567:15)
at nodeLinkFn (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:15155:24) <ion-nav-view name="menuContent" animation="slide-left-right"> ionic.bundle.js:18366

"ng-cordova.js:793:34" ->

return navigator.connection.type;

but i can successfully in console do:

> navigator.connection.type
"wifi"

just for the record in the app.js where i load loginControllers i have ngCordova as a dependency:

  var myApp = angular.module('myApp', [
    'ionic',
    'ngCordova',
   ...

sorry if its not a error related to ng-cordova ....

//

pelle

Make list in Docs for installing each plugin

List of plugins to install via Cordova CLI:

Network Plugin
cordova plugin add org.apache.cordova.network-information

Device Plugin
cordova plugin add org.apache.cordova.device

Contacts Plugin
cordova plugin add org.apache.cordova.contacts

Social Sharing Plugin
cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git

Statusbar Plugin
cordova plugin add org.apache.cordova.statusbar

Barcode Plugin
cordova plugin add https://github.com/wildabeast/BarcodeScanner.git

SQLite Plugin
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git

SplashScreen Plugin
cordova plugin add org.apache.cordova.splashscreen

Dialogs Plugin
cordova plugin add org.apache.cordova.dialogs

Globalization Plugin
cordova plugin add org.apache.cordova.globalization

Ionic Keyboard Plugin
cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git

refer to #7 for links

Breaks with angular 1.2.16-1.2.18

Hi,
I'm getting: "Uncaught object angular.js:78" when ng-cordova.js is referenced in my project.
Tried with 1.2.16 and 1.2.18
This happens before angular.run; If I remove 'ngCordova' from my angular module the error disappears.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.