Hi,
I have troubles when calling $ionicPush.register() - $ionicPush seems to be undefined.
![](https://dl.dropboxusercontent.com/s/zu3mb6k1f3c1x2e/Developer%20Tools%20-%20file%3A---android_asset-www-index.html_002.png?dl=0)
ionic-push.js gets loaded correctly and dependencies are set:
angular.module('meetat', [
'ionic',
'ngCordova',
'ionic.service.core',
'ionic.service.push',
'meetat.controllers',
'angular-carousel',
'ngRoute',
'ui.router'])
Controller code:
.controller('LoginCntrl', function ($scope, $http, $state, $ionicLoading, $rootScope, $ionicUser, $ionicPush) {
$scope.userId;
var fbLoginSuccess = function (userData)
{
facebookConnectPlugin.getAccessToken(function (token)
{
$scope.initUser();
}, function (err) {
});
};
$scope.login = function () {
facebookConnectPlugin.login(["public_profile, user_events, user_birthday, user_friends, user_photos"],
fbLoginSuccess,
function (error) {
alert("Login not possible.");
}
);
};
$scope.identifyUser = function () {
var user = $ionicUser.get();
if (!user.user_id) {
user.user_id = $scope.userId;
}
$ionicUser.identify(user).then(function () {
$scope.identified = true;
console.log('Identified user ' + user.name + '\n ID ' + user.user_id);
$scope.pushRegister();
});
};
// Registers a device for push notifications
$scope.pushRegister = function () {
console.log('Ionic Push: Registering user');
// Register with the Ionic Push service. All parameters are optional.
$ionicPush.register({
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
return true;
}
});
};
$scope.initUser = function () {
$scope.identifyUser();
[...]
};
$scope.getFacebookLoginStatus = function () {
[...]
};
$scope.getFacebookLoginStatus();
})
Additional information:
- $ionicUser.identify gets called without problems and the response is correct. Users appear @ Ionic Dashboard.
- The error does not appear when dev_mode set to true,
- All API keys are set (gcm_id as well) and verified multiple times.
Thanks for your help.