Closed jpike88 closed 7 years ago
Please see here: https://github.com/ToothlessGear/node-gcm/issues/279
My pull request was rushed. But this is a design issue inherent in either this library, node-gcm or gcm itself.
Like any library, It should be almost like a black box, where the most basic of arguments should achieve the desired effect consistently.
That above data object worked fine with APNS, so why can't it work fine with GCM?
Bear in mind, my use case is simple and probably representative of the majority of developers.
This is my entire script, so not sure what's going wrong here:
const settings = {
gcm: {
id: GCM_API_TOKEN
},
apn: {
token: {
key: KEY_PATH
keyId: 'abc',
teamId: '123',
}
},
};
const PushNotifications = require('node-pushnotifications');
const push = new PushNotifications(settings);
const registrationIds = [];
registrationIds.push('androidDeviceKey');
const data = {
title: 'I SHOW', // REQUIRED
body: 'ON ANDROID I DO NOT SHOW WITHOUT THE FIX I MADE', // REQUIRED
topic: 'com.app.APP'
};
// You can use it in node callback style
push.send(registrationIds, data, (err, result) => {
if (err) {
console.log(err);
} else {
console.log(result[0].message);
}
});
Edit: I read that message thread. Just made things even more confusing.
The problem is with how google manages android push notifications, it's a mess. Could you show the code on your app? I can help you there.
Also you can see here how to get the data from the notification: https://github.com/appfeel/cordova-push-notifications/blob/master/src/android/com/plugin/gcm/GCMIntentService.java#L103
The main purpose of this library is the one you described, but we should not break old implementations. Maybe the changes you proposed could be integrated, not replacing the existing ones.
It seems any time I touch something related to Google, it always leads into a mess. I'll tweak my android code to suit it and figure more out about what's going on here.
What the hell. It now works. I didn't change anything today, just ran it again. Nice job Google.
{ title: 'This Shows, // REQUIRED body: 'Uhhh should i show', // REQUIRED topic: 'some_stuff' }
That body doesn't show in the android notification.