trying migrate ionicpush getting errors anyway it:
option 1 - angular method
when put $ionicpush.init
per guide in app.js or anywhere matter, getting:
uncaught typeerror: $ionicpush.init not function
when check $ionicpush
has 2 methods, register , unregister. gets imported, whatever reason doesnt have .init
top of app.js
looks this:
.run(function(approotservice, $ionicplatform, $ionicpush, $cordovasplashscreen,$window, $timeout) { $ionicplatform.ready(function() { $ionicpush.init({ "debug": true, "onnotification": function(notification) { var payload = notification.payload; console.log(notification, payload); }, "onregister": function(data) { console.log(data.token); } }); $ionicpush.register();
option 2 - regular js way
put code in app.js
after $ionicplatform.ready()
var push = new ionic.push({ "debug": true, "onnotification": function(notification) { var payload = notification.payload; console.log(notification, payload); }, "onregister": function(data) { console.log(data.token); } }); push.register(function(token) { console.log("device token:",token.token); }); ionic.io();
still nothing, time error uncaught referenceerror: ionic not defined
ran both of these:
ionic add ionic-platform-web-client ionic plugin add phonegap-plugin-push
moved around ionic.io()
, not luck
i think have init io , activate debug/dev mode.
here steps...
ionic add ionic-platform-web-client ionic plugin add phonegap-plugin-push ionic io init ionic config set dev_push true .run(function($ionicplatform) { $ionicplatform.ready(function() { var push = new ionic.push({ "debug": true }); push.register(function(token) { console.log("device token:",token.token); }); }); })
checkout page setting push platforms (ios, android) http://docs.ionic.io/docs/push-from-scratch
Comments
Post a Comment