patrickheneise / angular-phonegap-push-notification Goto Github PK
View Code? Open in Web Editor NEW[deprecated] AngularJS module for Android and iOS push notification services
License: MIT License
[deprecated] AngularJS module for Android and iOS push notification services
License: MIT License
When I try to execute the code, the result is app is not defined referring to
app.onNotificationGCM = function (event) {
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
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);
}
});
}])
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???
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.