Git Product home page Git Product logo

angular-phonegap-push-notification's Introduction

AngularJS Phonegap/Cordova Push Notifications

Bower component for iOS and Android Push Notifcation services. Check out node-apn and node-gcmhttps://github.com/ToothlessGear/node-gcm) to implement push notification services on a node.js server.

Usage

  1. bower install angular-phonegap-push-notification
  2. Made sure the cordova-*.js script is in your .html file.
  3. Replace {your_sender_id} with your GCM sender id
  4. Include the push.js script, and this script's dependencies are included in your app.
  5. Add cordova as a module dependency to your app.

Workflow after optaining the device_id

  1. send the device_id to an application server
  2. store the device_id on the application server
  3. send push notifications with the device_id/token

Example

var result = push.registerPush(function (result) {
  if (result.type === 'registration') {
    localStorage.setItem('device_id', result.id);
    localStorage.setItem('device', result.device);
  }
});

License

MIT

angular-phonegap-push-notification's People

Contributors

aldatsa avatar alexproca avatar kaililleby avatar patrickheneise 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-phonegap-push-notification's Issues

Result undefined

var result = push.registerPush(function (result) {
......

I have replace sender ID with GCM sender Id, when I implement, I log result but It 's "undefined"
I use ionic, default have cordova.js , Do this need more plugin of cordova.js???

ReferenceError: app is not defined

Hello Patrick:

First of all, Thanks for this great Angular service it helps me to reduce development timeline.
However, I've tried to implement it with your lightning introduction and what I got the error from Chrome remote debugging console show:

ReferenceError: app is not defined

Could you please point me out the solution to patch push.js or something i missing cause this error ? Plus, My development env. is Ionic+Android 4.4.2 (I think the Android version is not matter to this error)

Thank you.

=== main.html ===

<ion-view>
  <ion-content padding="true">
    <div id="deviceready" class="blink">
        <p class="event listening">Connecting to Device</p>
        <p class="event received">Device is Ready</p>
    </div>
      <a ng-href="#/login" class="bar bar-footer bar-balanced">
        <div class="title">Login</div>
      </a>
  </ion-content>
</ion-view>

=== controllers.js ===

'use strict';
angular.module('Mobile.controllers', ['cordova'])
.controller('MainCtrl', ['$scope', 'push', function($scope, push) {

  var result = push.registerPush(function (result) {
    if (result.type === 'registration') {
      localStorage.setItem('device_id', result.id);
      localStorage.setItem('device', result.device);
    }
  });
}])

app is undefined

When I try to execute the code, the result is app is not defined referring to

app.onNotificationGCM = function (event) {

Implementation issue

Hi, I would like to use this module but I can not.
I have included the file and ready.js and push.js in my index.html

var myApp = angular.module('myApp', ['ngRoute', 'btford.phonegap.ready', 'phonegap']);

myApp.config(['$routeProvider', 
  function($routeProvider) {
    $routeProvider.
    when('/contacts', {
      templateUrl: 'partials/contacts.html',
      controller: 'ContactsCtrl'
    }).
    otherwise({
      redirectTo: '/contacts'
    });
  }]);

myApp.controller('ContactsCtrl', ['$scope', '$http', 'push',
  function($scope, $http, push) {

    var result = push.registerPush(function (result) {
  if (result.type === 'registration') {
    alert('device_id' + result.id);
    alert('device' + result.device);
  }

});

}]);

My index.html file

    ...
    <script type="text/javascript" src="phonegap.js"></script>
    <script src="js/jquery.js"></script>
    <script src="js/PushNotification.js"></script>
    <script src="js/angular.min.js"></script>
    <script src="js/angular-route.min.js"></script>
    <script src="js/ready.js"></script>
    <script src="js/push.js"></script>
    <script src="js/index.js"></script>
    ...

Thank's

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.