node-pushnotifications icon indicating copy to clipboard operation
node-pushnotifications copied to clipboard

Android GCM Weird behavior v1.6.2

Open DowsingUK opened this issue 4 years ago • 8 comments

Hi there I'm developing an app using Java I'm using your package and when I use these settings* everything works I even get silent push notifications in my Android devices I don't know why they're in silent mode I'm even using silent: false but I keep getting silent notifications I have tried every combination of settings and nothing else seems to work and then if I use this** or this*** I just get "error":"InternalServerError" after call ****

*gcm: { id: config.fcm_server_id, phonegap: true }

**gcm: { id: config.fcm_server_id, phonegap: false }

***gcm: { id: config.fcm_server_id }

****push.send(registrationIds, data).then(function(result) { log(result); //This prints this info here not in catch function so I'm guessing something's wrong in your side "method": "gcm", "multicastId": [ xxxxxxxxxxxxxxxxxx ], "success": 0, "failure": 1, "message": [ { ... "error": "InternalServerError" } ]

}) .catch(function(err) { log(err); //never gets call });

DowsingUK avatar Mar 27 '21 21:03 DowsingUK

@DowsingUK Hard to tell why you get silent notifications from the information you provided. Can you share a more complete example if your notification payload?

alex-friedl avatar Apr 03 '21 12:04 alex-friedl

I'm using same code as the example:

const settings = { gcm: { id: fcm_server_id, phonegap: true, // if false fails, if true works in silent mode }, };

push = new PushNotifications(settings);

const data = { title: hook.data.title, // REQUIRED for Android // topic: 'topic', // REQUIRED for iOS (apn and gcm) /* The topic of the notification. When using token-based authentication, specify the bundle ID of the app. * When using certificate-based authentication, the topic is usually your app's bundle ID. * More details can be found under https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns / body: body, // REQUIRED for Android priority: 'high', // gcm, apn. Supported values are 'high' or 'normal' (gcm). Will be translated to 10 and 5 for apn. Defaults to 'high' collapseKey: '', // gcm for android, used as collapseId in apn contentAvailable: true, // gcm, apn. node-apn will translate true to 1 as required by apn. delayWhileIdle: true, // gcm for android restrictedPackageName: '', // gcm for android dryRun: false, // gcm for android icon: '', // gcm for android tag: '', // gcm for android color: '', // gcm for android clickAction: '', // gcm for android. In ios, category will be used if not supplied locKey: '', // gcm, apn locArgs: '', // gcm, apn titleLocKey: '', // gcm, apn titleLocArgs: '', // gcm, apn retries: 1, // gcm, apn encoding: '', // apn badge: badge, // gcm for ios, apn sound: 'ping.aiff', // gcm, apn silent: false, // gcm, apn, will override badge, sound, alert and priority if set to true on iOS, will omit notification property and send as data-only on Android/GCM alert: { // apn, will take precedence over title and body title: title, body: body // details: https://github.com/node-apn/node-apn/blob/master/doc/notification.markdown#convenience-setters }, / * A string is also accepted as a payload for alert * Your notification won't appear on ios if alert is empty object * If alert is an empty string the regular 'title' and 'body' will show in Notification */ // alert: '', launchImage: '', // apn and gcm for ios action: '', // apn and gcm for ios category: '', // apn and gcm for ios // mdm: '', // apn and gcm for ios. Use this to send Mobile Device Management commands. // https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/3-MDM_Protocol/MDM_Protocol.html urlArgs: '', // apn and gcm for ios truncateAtWordEnd: true, // apn and gcm for ios mutableContent: 0, // apn threadId: '', // apn expiry: Math.floor(Date.now() / 1000) + 28 * 86400, // seconds timeToLive: 28 * 86400, // if both expiry and timeToLive are given, expiry will take precedency headers: [], // wns launch: '', // wns duration: '', // wns consolidationKey: 'my notification', // ADM };

DowsingUK avatar Apr 03 '21 17:04 DowsingUK

Do you need phonegap compatibility mode? Have you tried phonegap: false ? If phonegap=true the notification property will be set to undefined, which can result in a silent notification if you also don't set a sound or icon.

alex-friedl avatar Apr 05 '21 10:04 alex-friedl

Also you posted basically the example with empty default values but it's not clear which payload you specify in the body. I would assume your payload is incomplete. Please refer to https://github.com/ToothlessGear/node-gcm to see some example configurations for your Android use-case

alex-friedl avatar Apr 05 '21 10:04 alex-friedl

I've been using the same payload in a previous version 1.4.1 and everything works fine I'm actually using that version in production right now it's a stable one at least in my case just looking forward to update if you help me with this bug. I do not need phonegap mode actually the first thing I tried was disabling it with not positive outcome as I describe in the main post I have use phonegap: true and that's making every push notification a silent one if I remove phonegap property or set it to false I get "error": "InternalServerError"

DowsingUK avatar Apr 05 '21 23:04 DowsingUK

Would be interesting to get more details of InternalServerError response from Firebase. Any chance you can debug this on your end with some breakpoints or logs in your local node-gcm dependency? Or is there the possibility to get more details from the Firebase console?

alex-friedl avatar Apr 06 '21 20:04 alex-friedl

@DowsingUK Any update on this? Do you still experience these issues?

alex-friedl avatar Aug 11 '21 12:08 alex-friedl

Same issues with this package, push works fine if I send push from FCM console

DowsingUK avatar Aug 11 '21 16:08 DowsingUK