Push Notification Not Shown when App is OPEN - Android


#1

Hi guys!

Wondering if some of you had a problem with this. I am using full push notifications in Ionic with the phonegap-plugin-push.

Testing on Android when my app is closed/background my notification displays flawlessly but when I am using the app and I send a notification nothing is shown :confused:

Any chances someone could know what cloud be?

The cURL instruction is this one:

curl -X POST -H “Authorization: Bearer QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123” -H “Content-Type: application/json” -d ‘{
“tokens”: [“QWERTY123QWERTY123QWERTY123QWERTY123QWERTY123”],
“profile”: “QWERTY123”,
“notification”: {
“title”: “Hi”,
“message”: “Hello world!”,
“android”: {
“title”: “Title!”,
“message”: “Message!”
}
}
}’ “https://api.ionic.io/push/notifications

TY guys!


#2

Me too have this same problem…:confused:


#3

You can use ionic popup to show notification. Like that
"onNotification": function(notification) {
var alertPopup = $ionicPopup.alert({
title: “Notification”,
template: notification.text,
buttons: [
{
text: ‘OK’,
}]
});

      }

#4

ok ihuseynoff. I will try this one.:slight_smile:


#5

TY very much ihuseynoff works like a charm! Kudos!


#6

Hi ebocic/ihuseynoff. Excited to try the code. Where should I put it? On the “Ionic.Push” object?


#7

Nevermind…it works!

Here’s what i did:

var push = new Ionic.Push({
      // "debug": false
      "onNotification": function(notification) {
          console.log(JSON.stringify(notification));
          var alertPopup = $ionicPopup.alert({
              title: notification._raw.title,
              template: notification._raw.message,
              buttons: [{
                  text: 'OK',
              }]
          });
      }

    });