How to send and receive push notif from apps.ionic.io?


#1

Hi, im trying to using this http://docs.ionic.io/v1.0/docs/push-install and implement it on my app.

angular.module('starter', ['ionic', 'starter.controllers', 'ionic.service.core', 'ionic.service.push'])

.config(['$ionicAppProvider', function($ionicAppProvider) {
  // Identify app
  $ionicAppProvider.identify({
    // Your App ID
    app_id: 'XXX',
    // The public API key services will use for this app
    api_key: 'XXX',
    // Your GCM sender ID/project number (Uncomment if supporting Android)
    gcm_id: 'XXX'
  });

}])

.run(function($ionicPlatform, $rootScope, $ionicPush, $cordovaPush) {
  $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();
    }
  });

  $ionicPush.register({
    canShowAlert: false, //Should new pushes show an alert on your screen?
    canSetBadge: true, //Should new pushes be allowed to update app icon badges?
    canPlaySound: false, //Should notifications be allowed to play a sound?
    canRunActionsOnWake: true, // Whether to run auto actions outside the app,
    onNotification: function(notification) {
      // Called for each notification.
    }
  }, {
    user_id: 'ionic101',
    username: 'ionitron',
    age: 9001
  });

  $rootScope.$on('$cordovaPush:tokenReceived', function(event, data) {
    console.log('Got token', data.token, data.platform);
    // Do something with the token
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
    .state('home', {
      url: "/home",
      templateUrl: "templates/home.html",
      controller: 'AppCtrl'
    });

  $urlRouterProvider.otherwise('/home');

});

I got this :

But i dont know how to send push notif. And in Ionic Push, my device is not registered.
Could somebody help me to fix it?