离子设置推送 - 无法读取未定义的 属性
ionic setting up push - Cannot read property of undefined
我正在通过 ionic 开发推送应用程序。我从 ionic 本身遵循了本教程:http://docs.ionic.io/docs/push-from-scratch
正在注册用户 - 完美!
设置推送通知不
两周前它实际上运行良好,能够做我想做的一切。我希望 ngCordova/ionic 有一些重大变化,但我找不到。
错误
Cannot read property 'pushNotification' of undefined
at line: $ionicPush.register({
痕迹
TypeError: Cannot read property 'pushNotification' of undefined
at Object.register (ng-cordova.js:6362)
at init (ionic-push.js:146)
at ionic-push.js:309
at new Q (ionic.bundle.js:22259)
at Q (ionic.bundle.js:22246)
at Object.register (ionic-push.js:270)
at Scope.$scope.pushRegister (controllers.js:60)
at $parseFunctionCall (ionic.bundle.js:21172)
at ionic.bundle.js:53674
at Scope.$get.Scope.$eval (ionic.bundle.js:23228)
和代码 (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 a user with the Ionic User service
$scope.identifyUser = function() {
console.log('Ionic User: Identifying with Ionic User service');
var user = $ionicUser.get();
if(!user.user_id) {
// Set your user_id here, or generate a random one.
user.user_id = $ionicUser.generateGUID();
};
// Add some metadata to your user object.
angular.extend(user, {
name: 'Ionitron',
bio: 'I come from planet Ion'
});
// Identify your user with the 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 with the Ionic Push service. All parameters are optional.
$ionicPush.register({ //ERROR FIRES HERE
canShowAlert: true, //Can pushes show an alert on your screen?
canSetBadge: true, //Can pushes update app icon badges?
canPlaySound: true, //Can notifications play a sound?
canRunActionsOnWake: true, //Can run actions outside the app,
onNotification: function(notification) {
// Handle new push notifications here
// console.log(notification);
return true;
}
});
alert('bla2');
};
})
我更新了 cordova,添加和删除了 ionic ready 监听器。我在 phone 上试过 运行 它给出了这个错误:
你有什么建议吗?
试试看
ionic config set dev_push true
在终端中。
我在这里发帖:https://github.com/driftyco/ionic-push-tutorial-app/issues/7
我正在通过 ionic 开发推送应用程序。我从 ionic 本身遵循了本教程:http://docs.ionic.io/docs/push-from-scratch
正在注册用户 - 完美! 设置推送通知不
两周前它实际上运行良好,能够做我想做的一切。我希望 ngCordova/ionic 有一些重大变化,但我找不到。
错误
Cannot read property 'pushNotification' of undefined
at line: $ionicPush.register({
痕迹
TypeError: Cannot read property 'pushNotification' of undefined
at Object.register (ng-cordova.js:6362)
at init (ionic-push.js:146)
at ionic-push.js:309
at new Q (ionic.bundle.js:22259)
at Q (ionic.bundle.js:22246)
at Object.register (ionic-push.js:270)
at Scope.$scope.pushRegister (controllers.js:60)
at $parseFunctionCall (ionic.bundle.js:21172)
at ionic.bundle.js:53674
at Scope.$get.Scope.$eval (ionic.bundle.js:23228)
和代码 (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 a user with the Ionic User service
$scope.identifyUser = function() {
console.log('Ionic User: Identifying with Ionic User service');
var user = $ionicUser.get();
if(!user.user_id) {
// Set your user_id here, or generate a random one.
user.user_id = $ionicUser.generateGUID();
};
// Add some metadata to your user object.
angular.extend(user, {
name: 'Ionitron',
bio: 'I come from planet Ion'
});
// Identify your user with the 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 with the Ionic Push service. All parameters are optional.
$ionicPush.register({ //ERROR FIRES HERE
canShowAlert: true, //Can pushes show an alert on your screen?
canSetBadge: true, //Can pushes update app icon badges?
canPlaySound: true, //Can notifications play a sound?
canRunActionsOnWake: true, //Can run actions outside the app,
onNotification: function(notification) {
// Handle new push notifications here
// console.log(notification);
return true;
}
});
alert('bla2');
};
})
我更新了 cordova,添加和删除了 ionic ready 监听器。我在 phone 上试过 运行 它给出了这个错误:
你有什么建议吗?
试试看
ionic config set dev_push true
在终端中。
我在这里发帖:https://github.com/driftyco/ionic-push-tutorial-app/issues/7