Open buymybm100 opened 3 years ago
Seems to be the same issue reported here : https://github.com/activitree/meteor-push/issues/35 ie, An exception is thrown in setBadge() in "lib/client/cordova.js"
If the code in setBadge() is hashed out , I can get notifications from the CordovaPush.push.on("notification", fn) handler. The badge on the App icon is set correctly even with the code hashed out in setBadge().
ERROR: Unhandled Promise rejection: undefined is not a function (near '...this.once...') ; Zone:
setBadge (count) {
/*---- **hashed out temporarily** ----
this.once('ready', () => {
if (/ios/i.test(device.platform)) {
this.log('PushHandle.setBadge:', count)
// xxx: at the moment only supported on iOS
this.push.setApplicationIconBadgeNumber(() => {
this.log('PushHandle.setBadge: was set to', count)
}, (e) => {
PushEventState.emit('error', {
type: getService() + '.cordova',
error: 'PushHandle.setBadge Error: ' + e.message
})
}, count)
}
})
-------- */
}
what does setBadge() do ?
Best wishes, Beemer
Hi Paul, an update on this .. I got the 'IOS background notifications' to work after 1) hashing out the this.once("ready") code in setBadge() ... or putting a TRY-CATCH around it so the App doesn't crash and 2) hard-coding the 'content-available': 1 in the payload (in server/notification.js)
Not sure why this.once("ready") isn't working. With regards to the 'contentAvailable', this parameter is not set in the notification.js .. so, will be a quick fix.
Works with METEOR@2.2
Thanks again , your work is much appreciated !
Beemer
@buymybm100 i have a question have you updated the cordova plugins? I do not see the authorization notification on my app on ios? are they present on your app?
no, i just used the cordova plugins specified in the example directory.
re: "authorization notification" - do you mean the popup message on the Mobile that ask if you allow notifications ? Yes, i get that. It comes up after the call to CordovaPush.Configure({}).. comes up about 2-3 seconds after the call.
Hi @buymybm100, I have similar problem and able to redirect my page on notification receive when I change my payload. It's also mentioned in documentation : phonegap-push-plugin
try this one for payload (ios only):
{
"registration_ids": [
“this is yoour device id”
],
"notification": {
"body": “Just check it out guys, it’s cheap yet qualified!”,
"title": “Buy Our Product Now!,
"subtitle": “Just Stylist“,
"sound": "default",
"tag": "1"
},
"data": {
"redirectUrl": "/merchandise/merchandiseDetail/_this_is_product_id_x7gdyneidjhma”
},
"content_available": true
}
for android you must implement different payload as mentioned in the document. I hope it can help.
Thanks & Regards
Hi Paul, Thanks so much for this package! I used your instructions and the example to get up and running. I am able to send notifications and receive them in pop-ups on the Mobile (outside the App). However, the CordovaPush.on("notifications") handler is not being called.
I am using your userPushNotification() meteor method .. and have the 'contentAvailable' flag set to true. Below is the Final notification right before shoot out but content-available is not set. ....
Seems 'content-available' is needed for background notifications to work on IOS. ref: https://github.com/havesource/cordova-plugin-push/blob/master/docs/PAYLOAD.md#ios-behaviour
I have tried hard-coding "content-available": 1 in the payload (in server/notification.js) but that didn't work either.
Have I missed something ? T
Best wishes, Beemer