Push notification in ionic framework not working


#1

I’m doing push notification in ionic framework. I getting only alert. I need to get notification.

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic',  'ionic.service.core','ngCordova', 'ionic.service.push'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(['$ionicAppProvider', function($ionicAppProvider) {
  $ionicAppProvider.identify({
    app_id: '38676e5c',
    api_key: '76e051384cb6095e751db3791e26b2bd1162cceccd039f2a',
    dev_push: true
  });
}])

.controller('PushCtrl', function($scope, $rootScope, $ionicUser, $ionicPush) {

  $rootScope.$on('$cordovaPush:tokenReceived', function(event, data) {
    alert('Success: ' + data.token);
    console.log('name: ' + data.token + "--- Id: ");
    console.log('Got token: ' , data.token, data.platform);
    $scope.token = data.token;
  });

  $scope.identifyUser = function() {
    var user = $ionicUser.get();

    if (!user.user_id) {
      user.user_id = $ionicUser.generateGUID();
    }

    angular.extend(user, {
      name: 'My Name',
      bio: 'I am awesome'
    });

    $ionicUser.identify(user).then(function() {
      $scope.identified = true;
      console.log('name: ' + user.name + "--- Id: " + user.user_id);
    });
  };

  $scope.pushRegister = function() {
    $ionicPush.register({
      canShowAlert: true,
      canSetBadge: true,
      canPlaySound: true,
      canRunActionsOnWake: true,
      onNotification: function(notification) {
        // handle your stuff
        return true;
      }
    });
  };
});

i can’t able to save android device token for users (ionic.io)
i need to send notifcation for particular device…

Any example???