Closed ojczeo closed 5 years ago
I think the error message is pretty clear. Anything I can help you with? If your debugging is set to true, I think you should see the final notification before it sends out. Your Android data object should only have key of data type string. This is the requirement of Firebase.
You have multiple data objects there (data - global, androidData, iosData). Android data.keys should be string. For IOS or Web they can be anything.
@paulincai the problem is I'm not sending any androidData, notifications object looks like that:
{
title: `Someone liked your product. `,
body: `Product name.`,
badge: 1,
userId: "4DgfWwrBgAFXTuGfc"
}
Final notification right before shoot out: {
I20191106-12:50:16.440(1)? "android": {
I20191106-12:50:16.441(1)? "data": {
I20191106-12:50:16.441(1)? "title": "Someone liked your post. ",
I20191106-12:50:16.441(1)? "body": "testlikes your post test.",
I20191106-12:50:16.441(1)? "tag": "undefined",
I20191106-12:50:16.441(1)? "channel_id": "com.shopvine.shopvine"
I20191106-12:50:16.441(1)? },
I20191106-12:50:16.441(1)? "fcm_options": {
I20191106-12:50:16.441(1)? "analytics_label": "activitreeSomething"
I20191106-12:50:16.441(1)? }
I20191106-12:50:16.441(1)? },
I20191106-12:50:16.441(1)? "apns": {
I20191106-12:50:16.441(1)? "headers": {
I20191106-12:50:16.441(1)? "apns-priority": "10"
I20191106-12:50:16.441(1)? },
I20191106-12:50:16.441(1)? "payload": {
I20191106-12:50:16.442(1)? "aps": {
I20191106-12:50:16.442(1)? "alert": {
I20191106-12:50:16.442(1)? "title": "Someone liked your post. ",
I20191106-12:50:16.442(1)? "body": "testlikes your post test."
I20191106-12:50:16.442(1)? },
I20191106-12:50:16.442(1)? "badge": 1,
I20191106-12:50:16.442(1)? "sound": "",
I20191106-12:50:16.442(1)? "data": {}
I20191106-12:50:16.442(1)? }
I20191106-12:50:16.442(1)? },
I20191106-12:50:16.442(1)? "fcm_options": {
I20191106-12:50:16.442(1)? "analytics_label": "activitreeSomething"
I20191106-12:50:16.442(1)? }
I20191106-12:50:16.442(1)? },
I20191106-12:50:16.442(1)? "webpush": {
I20191106-12:50:16.443(1)? "headers": {
I20191106-12:50:16.443(1)? "Urgency": "high"
I20191106-12:50:16.443(1)? },
I20191106-12:50:16.443(1)? "data": {},
I20191106-12:50:16.443(1)? "notification": {
I20191106-12:50:16.443(1)? "title": "Someone liked your post. ",
I20191106-12:50:16.443(1)? "body": "testlikes your post test."
I20191106-12:50:16.443(1)? },
I20191106-12:50:16.443(1)? "fcm_options": {
I20191106-12:50:16.443(1)? "link": "https://some_photo_url_or_link_to_something"
I20191106-12:50:16.443(1)? }
I20191106-12:50:16.443(1)? },
@paulincai maybe it's related to place below? it's trying to send Anroid message event when it's not defined: https://github.com/activitree/meteor-push/blob/5cd4677cf566b35cc1ed7b7d516274b0d27f335e/lib/server/pushToDevice.js#L122-L144
Ok... you can read here: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads. Your Android notification will always go as 'data'. You can overwrite keys using the androidData object. So in your case above, I see 'tag' is undefined. I believe that is your problem.
i don't event want to use android - only APN. I didnt define any tag in Android data.
śr., 6 lis 2019, 13:27 użytkownik Paul Ailincai notifications@github.com napisał:
Ok... you can read here: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads. Your Android notification will always go as 'data'. You can overwrite keys using the androidData object. So in your case above, I see 'tag' is undefined. I believe that is your problem.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/activitree/meteor-push/issues/17?email_source=notifications&email_token=AAOUBS6GLTYA3I3NNYVFJVLQSKZZTA5CNFSM4JJTMVCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDGLQHA#issuecomment-550287388, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUBS7X7S4Z4ED6TDHBUUDQSKZZTANCNFSM4JJTMVCA .
I understand you don't use Android but in Firebase as you probably notices there is one notification going out for all so we need to satisfy all conditions. 'Tag' is not the problem. Please see this successful note for your reference. I hope this can help you to identify your issue. The error message you receive is generated by Firebase.
I20191106-17:15:37.737(4)? Push: Send message "A new friendship request" to user: [ 'kut7TGfjfQZu7SNMK', 'kut7TGfjfQZu7SNMK' ]
I20191106-17:15:37.749(4)? Send to token { apn: 'dpDvSS-QR5s:APA91bHcuNqKW_UPvEU8xxxxxuOEe5CU091WK0TbZKe9r9dQ_D3DjwXURRKmcBhKR6C3YVPi-NmqtHX-4PKR6CUxlGLfrNujHpcrHE7RYQVOWy65KN-fFHDl3P8TPgyFapuA2rAl' }
I20191106-17:15:37.750(4)? Final notification right before shoot out: {
I20191106-17:15:37.750(4)? "android": {
I20191106-17:15:37.751(4)? "priority": "HIGH",
I20191106-17:15:37.751(4)? "data": {
I20191106-17:15:37.751(4)? "title": "A new friendship request",
I20191106-17:15:37.751(4)? "body": "Jimmy started following you",
I20191106-17:15:37.751(4)? "icon": "statusbaricon",
I20191106-17:15:37.751(4)? "color": "#337FAE",
I20191106-17:15:37.752(4)? "sound": "note",
I20191106-17:15:37.752(4)? "tag": "undefined",
I20191106-17:15:37.752(4)? "channel_id": "com.activitree",
I20191106-17:15:37.752(4)? "notification_priority": "PRIORITY_DEFAULT",
I20191106-17:15:37.752(4)? "visibility": "PRIVATE",
I20191106-17:15:37.753(4)? "image": "https://assets.activitree.com/covers/activitree.jpg",
I20191106-17:15:37.753(4)? "thisIsGlobal": "true",
I20191106-17:15:37.753(4)? "haideMah": "pe bune",
I20191106-17:15:37.753(4)? "vaiAsaceva": "tadam"
I20191106-17:15:37.753(4)? },
I20191106-17:15:37.753(4)? "fcm_options": {
I20191106-17:15:37.754(4)? "analytics_label": "activitreeSomething"
I20191106-17:15:37.754(4)? }
I20191106-17:15:37.754(4)? },
I20191106-17:15:37.754(4)? "apns": {
I20191106-17:15:37.754(4)? "headers": {
I20191106-17:15:37.754(4)? "apns-priority": "10"
I20191106-17:15:37.755(4)? },
I20191106-17:15:37.755(4)? "payload": {
I20191106-17:15:37.755(4)? "aps": {
I20191106-17:15:37.755(4)? "alert": {
I20191106-17:15:37.755(4)? "title": "A new friendship request",
I20191106-17:15:37.756(4)? "body": "Jimmy started following you",
I20191106-17:15:37.756(4)? "launch-image": ""
I20191106-17:15:37.756(4)? },
I20191106-17:15:37.756(4)? "badge": 1,
I20191106-17:15:37.756(4)? "sound": "note.caf",
I20191106-17:15:37.757(4)? "data": {
I20191106-17:15:37.757(4)? "thisIsGlobal": "mama",
I20191106-17:15:37.757(4)? "thisisIOS": "tada"
I20191106-17:15:37.757(4)? }
I20191106-17:15:37.757(4)? }
I20191106-17:15:37.757(4)? },
I20191106-17:15:37.757(4)? "fcm_options": {
I20191106-17:15:37.758(4)? "analytics_label": "activitreeSomething",
I20191106-17:15:37.758(4)? "image": "https://assets.activitree.com/covers/activitree.jpg"
I20191106-17:15:37.758(4)? }
I20191106-17:15:37.758(4)? },
I20191106-17:15:37.758(4)? "webpush": {
I20191106-17:15:37.758(4)? "headers": {
I20191106-17:15:37.758(4)? "Urgency": "high",
I20191106-17:15:37.759(4)? "TTL": "3600000"
I20191106-17:15:37.759(4)? },
I20191106-17:15:37.759(4)? "data": {
I20191106-17:15:37.759(4)? "thisIsGlobal": "Nope, it isn't"
I20191106-17:15:37.759(4)? },
I20191106-17:15:37.759(4)? "notification": {
I20191106-17:15:37.760(4)? "title": "A new friendship request",
I20191106-17:15:37.760(4)? "body": "Jimmy started following you",
I20191106-17:15:37.760(4)? "icon": "https://assets.activitree.com/images/activitree-logo-r.jpg",
I20191106-17:15:37.760(4)? "image": "https://assets.activitree.com/covers/activitree.jpg"
I20191106-17:15:37.760(4)? },
I20191106-17:15:37.760(4)? "fcm_options": {
I20191106-17:15:37.761(4)? "link": "https://assets.activitree.com/activities/lg/kayaking.jpg"
I20191106-17:15:37.761(4)? }
I20191106-17:15:37.761(4)? },
I20191106-17:15:37.761(4)? "token": "dpDvSS-QR5s:APA91bHcuNqKW_UPvEU8DTHICyA56uOEe5CU091WK0TbZKe9r9dQ_D3DjwXURRKmcBhKR6C3YVPi-NmqtHX-4PKR6CUxxxxxpcrHE7RYQVOWy65KN-fFHDl3P8TPgyFapuA2rAl"
I20191106-17:15:37.761(4)? }
I20191106-17:15:37.796(4)? Push: Sent message "A new friendship request" to 1 ios apps | 0 android apps | 0 web apps
I20191106-17:15:38.733(4)? Successfully sent message: projects/activitree-6456f/messages/1573046138408620
@paulincai I've forked your code, and disabled part of your code related to Android. It's working now like a charm. I think there is a problem with default values. Anyway thanks a lot for help! :)
const note = {
// android: {
// // ttl: '86400s', // use default max of 4 weeks
// // collapse_key: string,
// priority: defaults.priority,
// // restricted_package_name: string,
// data: {
// title: mongoNote.title,
// body: mongoNote.body,
// icon: mongoNote.icon || defaults.icon,
// color: mongoNote.color || defaults.color,
// sound: mongoNote.sound || defaults.sound,
// tag: `${mongoNote.notId}`,
// // click_action: mongoNote.action
// channel_id: mongoNote.channelId || defaults.channelId || defaults.topic,
// notification_priority: mongoNote.notificationPriority || defaults.notificationPriority,
// visibility: mongoNote.visibility || defaults.visibility,
// // notification_count: mongoNote.badge || defaults.badge, // this is supposed to be a number, can't send it because I need it to be a string.
// image: mongoNote.imageUrl || defaults.imageUrl,
// ...globalData,
// ...noteAndroidData
// },
// fcm_options: {
// analytics_label: mongoNote.analyticsLabel || defaults.analyticsLabel
// }
// },
apns: {
headers: {
'apns-priority': defaults.apnsPriority,
},
payload: {
aps: {
alert: {
title: mongoNote.title,
body: mongoNote.body,
'launch-image': mongoNote.launchImage || defaults.launchImage
},
badge: mongoNote.badge || defaults.badge,
sound: mongoNote.sound ? `${mongoNote.sound}.caf` : defaults.sound ? `${defaults.sound}.caf` : '',
// 'click-action' // TODO check on this,
data: {
...defaults.data,
...defaults.iosData,
...globalData,
...noteIosData
}
}
},
fcm_options: {
analytics_label: mongoNote.analyticsLabel || defaults.analyticsLabel,
image: mongoNote.imageUrl || defaults.imageUrl
}
},
// webpush: {
// headers: {
// Urgency: 'high',
// TTL: defaults.webTTL, // mandatory, in seconds
// },
// data: {
// ...defaults.data,
// ...defaults.webData,
// ...globalData,
// ...noteWebData
// },
// notification: {
// title: mongoNote.title,
// body: mongoNote.body,
// icon: mongoNote.webIcon || defaults.webIcon,
// image: mongoNote.imageUrl || defaults.imageUrl
// /*
// actions: [
// {
// action: mongoNote.action || defaults.action,
// title: 'Book Appointment'
// }
// ]*/
// }, // Can take valued from here: https://developer.mozilla.org/en-US/docs/Web/API/Notification.
// fcm_options: {
// link: mongoNote.action || defaults.action
// }
// }
}
Ok, I tried to understand what might be the problem here. I think the package is ok, no issues there. I tried to implement as much as possible of the Firebase-Admin configurations and notification keys. It is true, you can't really opt out from one or another but I think you shouldn't. I guess most of the users would aim for all 3: IOS, Android and Web. Or perhaps there are people interested particularly in all mobiles or only the web/PWA.
The startup/server/push.js
file in the example provides defaults which are meant to satisfy all required values. You may have a look here: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification.
It seems that when an icon, or color, or sound etc are not specified, that error is presented. I'd suggest for you to start from the defaults I provided and fine tune for your needs, particularly for your IOS and leave Android untouched. It should then work ok. I am not able to find what are the mandatory key for Android. Anyway I manually removed them from defaults and observed where things start to fail. Thanks for your input on this. This was some necessary learning.
When I'm trying to send notifications using
Push.send
getting this error: