ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 208 forks source link

Heads-up notifications are not working #335

Closed iamromec closed 4 years ago

iamromec commented 4 years ago

I'm trying to send a notification with the highest priority but it's working like a normal notification. Anyone who's maintaining this plugin could look into the problem or if someone knows the solution.

message = new gcm.Message({
          priority: 2,
          contentAvailable: true,
          data: data,
          notification: {
            title: '*****',
            body: data.body,
            icon: 'ic_stat_ic_notification',
            color: '#0cd1e8',
            vigrationPattern: [400, 200],
            ledColor: [255, 0, 0, 1],
            notId: parseInt(Math.random() * new Date().getSeconds(), 10)
          }
        });

Neither heads-up notification is coming nor Vibration nor LED.

Could anyone please tell me what's wrong?

Thank you.

eladnava commented 4 years ago

Hi @iamromec, I'm not entirely sure where you got these key names from (vigrationPattern, ledColor, and notId).

They're not mentioned in the FCM notification payload option table.

You can only send notification keys mentioned in our docs: https://github.com/ToothlessGear/node-gcm#notification-payload-option-table

eladnava commented 4 years ago

Here's a possible solution for sending heads-up notifications: https://stackoverflow.com/a/39682826/1123355

iamromec commented 4 years ago

@eladnava I was experimenting with these keys: vigrationPattern, ledColor, and notId. Because this is how I want. As notifications are not being vibrated nor showing any LED.

And it does not show a heads up notification even with the given dataset. And how can I achieve this LED and vibration? I cannot why?

iamromec commented 4 years ago

Also setWhen() is missing.

iamromec commented 4 years ago

And why have you closed this issue as it's not resolved yet...?

hypesystem commented 4 years ago

Hi @iamromec these aren't really questions about the library, but rather how to make FCM work. A question like this probably fits better on StackOverflow or similar sites :smile:

iamromec commented 4 years ago

@hypesystem It is a question about the library. Why 'ledColor, vibrationPattern, when' keys are missing which are given in the official doc of the FCM notifications? And why the expected behavior is not working of heads-up notification? I went through SO and other forums and saw somewhere that priority key's value has been deprecated from 'PRIORITY_HIGH' to 'IMPORTANCE_HIGH'.

I don't see it's a run-time change.

hypesystem commented 4 years ago

Hi @iamromec, see @eladnava's response -- he couldn't find them in the documentation. If you think he hasn't looked the right place, please link to where it is in the documentation, and we can look at this again :smile:

eladnava commented 4 years ago

Official FCM notification payload table: https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support

eladnava commented 4 years ago

One thing's for sure, vigrationPattern can't have been a real key as there's a typo in the word vibration.