cordova - ionic setting up push - Cannot read property of undefined -
i'm working on push app via ionic. followed tutorial ionic itself: http://docs.ionic.io/docs/push-from-scratch
registering users - works perfect! setting push notifications don't
it worked 2 weeks ago, able wanted. expect breaking change in ngcordova/ionic can't find it.
the error
cannot read property 'pushnotification' of undefined @ line: $ionicpush.register({
the trace
typeerror: cannot read property 'pushnotification' of undefined @ object.register (ng-cordova.js:6362) @ init (ionic-push.js:146) @ ionic-push.js:309 @ new q (ionic.bundle.js:22259) @ q (ionic.bundle.js:22246) @ object.register (ionic-push.js:270) @ scope.$scope.pushregister (controllers.js:60) @ $parsefunctioncall (ionic.bundle.js:21172) @ ionic.bundle.js:53674 @ scope.$get.scope.$eval (ionic.bundle.js:23228)
and code (controllers.js)
angular.module('starter.controllers', []) .controller('dashctrl', function($scope, $rootscope, $ionicuser, $ionicpush) { // // handles incoming device tokens $rootscope.$on('$cordovapush:tokenreceived', function(event, data) { alert("successfully registered token " + data.token); console.log('ionic push: got token ', data.token, data.platform); $scope.token = data.token; }); // // identifies user ionic user service $scope.identifyuser = function() { console.log('ionic user: identifying ionic user service'); var user = $ionicuser.get(); if(!user.user_id) { // set user_id here, or generate random one. user.user_id = $ionicuser.generateguid(); }; // add metadata user object. angular.extend(user, { name: 'ionitron', bio: 'i come planet ion' }); // identify user ionic user service $ionicuser.identify(user).then(function(){ $scope.identified = true; alert('identified user ' + user.name + '\n id ' + user.user_id); }); }; $scope.pushregister = function() { console.log('ionic push: registering user'); alert('bla'); // register ionic push service. parameters optional. $ionicpush.register({ //error fires here canshowalert: true, //can pushes show alert on screen? cansetbadge: true, //can pushes update app icon badges? canplaysound: true, //can notifications play sound? canrunactionsonwake: true, //can run actions outside app, onnotification: function(notification) { // handle new push notifications here // console.log(notification); return true; } }); alert('bla2'); }; })
i updated cordova, added , removed ionic ready listener. tried running on phone gave error:
do have suggestions?
try ionic config set dev_push true
in terminal.
i posted here: https://github.com/driftyco/ionic-push-tutorial-app/issues/7
Comments
Post a Comment