Ionic-Push: No device token (Android)


#1

Hi guys,

i can identify and register for push with dev_push = true in my browser.
All works well.

But on my Device (Moto G), i can only identify users, but don’t get any device token.
I receive a log “Registered OK”, but nothing more.

My Code:

.controller('SettingsCtrl', function ($scope, $state, Camera, $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();
    };

    console.log(user);

    // 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);
    });
};


// Registers a device for push notifications and stores its token
$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
            console.log('On notification: ' +  JSON.stringify(notification));
            return true;
        }
    });
};

})