0

I am using Azure Notification Hub and Phonegap push plugin and sending push notifications to android phones trough this payload:

{  
   "data":{  
      "title":"Ex",
      "message":"Notification Hub test notification",
      "content-available":"1",
      "uuid":"6a1da769-e499-11e7-aa20-de2b503f5007",
      "category":"sales-offer"
   }
}

But the problem is that I only get the notification in the tray with an icon its not showing on the sceen with info. I need to open the tray to get the info. I want it to show on the screen with info (body, icon and title).

Can I add something to the payload, or a setting in my app to change this behaviour?

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
christian
  • 57
  • 5
  • Answer - https://stackoverflow.com/a/47303763/4647628 – Aks4125 Feb 07 '18 at 10:52
  • I have read the post you refered to and its refering to a notification builder. Are you saying that I need to create the Notification my self trough notification builder? Iam using cordova and havent done that before. Is it possible with cordova? – christian Feb 07 '18 at 11:04
  • Refer this doc: https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-cordova-get-started-push and see if you get some idea. – Swikruti Bose Feb 07 '18 at 11:13
  • good question, christian did you find any solution? – Erti-Chris Eelmaa Jan 22 '19 at 13:26

1 Answers1

0

You need to configure the default notification channel and increase the importance.

async function createNotificationChannel ({channelId, description, importance}) {
  if (device.platform.toLowerCase() !== 'android') {
    return false;
  }

  // code runs only on android platform :)
  const wAny: any = window;
  return new Promise((resolve, reject) => {
    wAny.PushNotification.createChannel(
      () => {
        resolve(true)
      },
      () => {
        resolve(false)
      },
      {
        id: channelId,
        description: description,
        importance: importance,
        visibility: 1,
        vibration: true
      }
    );
  });
}

Before calling PushNotification.init, call this:

const channelCreated = await createNotificationChannel(
  {
    channelId: 'PushPluginChannel',
    description: 'Important notifications',
    importance: 5
  });

I also threw in priority: 2 in the payload for older devices.

Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78