Himanshu Himanshu - 2 months ago 30
Android Question

Why IONIC push notification looks like Javascript alert?

I am successfully able to send push notifications using IONIC Framework. But these notifications doesn't looks like I receive other android notifications, rather it these looks like normal Javascript alert.

Is there any setting to set push notification type like (alert or something else) ?

I go through the following link : https://devdactic.com/ionic-push-notifications-guide/

If someone has faced and resolved this, then please comment.


  1. First screenshot shows push notification as Javascript alert.

  2. Second screenshot shows default Android notification after locking phone's screen.

  3. Third screenshot shows default Android notification after unlocking screen



Alert type notification

Default Android notification on lock screen

Default Android notification after unlocking screen

Answer

I solved this problem by applying below code to $ionicPlatform.ready in my app.js file which shows notifications with onNotification event, if onNotification is not present then IONIC show default Javascript alert.

var push = new Ionic.Push({
    onNotification:  function(notification) {
            var payload = notification.payload;
            console.log(notification, payload);
          },
    pluginConfig: {
      ios: {
        alert: true,
        badge: true,
        sound: true
      },
      android: {
        sound: true,
        vibrate: true,
        forceShow: true,
        iconColor: "#601dc2"
      },
    }
  });
Comments