0

I am doing project in which i have to use ionic push notification .my push notification is working properly and i am receiving notification and able to send it but the problem is after receiving notification i have to open specific page which is notification PAGE also i want to set the badges on notification

here is my code

   $scope.login = function () {
     $http({
          method: "post",
          url: "http/employee-connect/oauth/token",
          data:  "username="+$scope.data.username+"&password="+$scope.data.password+"&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=mai",
          withCredentials: true,
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        })
          .success(function (data){
                    //////////////notification Token////////////
           var push = new Ionic.Push({
          "debug": false; //Can run actions outside the app,
          "onNotification": function(notification) {
            var payload = notification.payload;
            console.log(notification, payload);
            },
          "onRegister": function(data) {
            var PushNotToken=data.token;
            console.log("PushNotificationToken="+PushNotToken);
            if(PushNotToken!=null) {
                  $http({
                    method: "post",
                    url: baseUrl+"notification-tokens/addToken="+PushNotToken,

                    withCredentials: true,
                    headers: {
                     'Content-Type':'application/json',
                      'Accept' : 'text/plain',
                      'Authorization' : ''+window.localStorage.getItem("token_type")+' '+window.localStorage.getItem("token")
                    }
                  })
                  .success(function(data) {
                    alert("data"+data);
                    console.log("PushNotToken send successfully. "+PushNotToken);                   
                  })
                  .error(function(data, status) {                  
                    console.log("PushNotToken NOT send successfully. "+PushNotToken);      
                  });

            }           
          },
          "pluginConfig": {
            "ios": {
              "badge": true,
              "sound": true
             },
             "android": {
               "iconColor": "#343434"
             }
          } 
        }) ;
                    var callback = function(pushToken) {
                      console.log(pushToken.token);
                    }

                    push.register(callback);

i am registering my device on the success of login and then sending the token to my server .

Now i want

1>open the specific page when the user click on notification

2>set the badges(i have to do this for android )is this possible to set the badges in android.

Mahesh Nighut
  • 115
  • 1
  • 10

0 Answers0