Closed rwillett closed 7 years ago
Further investigation shows inconsistent behaviour when sending the same data from the PushWoosh web app.
We log on to the PushWoosh website and send down a test message "test1" to the app (which is running but in the background). We only send it to the single device we have configured as a test device.
We send down test1, test2, test 3.... etc. Each time we have set badge to 0 in the web app. Sometimes, all the previous test messages are cleared, but mostly the new test message is appended to the top of the message queue. We can't seem to reproduce the behaviour when the app is killed.
Rob
If the badges are not set for the app, then setting badges to 0 won't clear the notification center. You have to set badges to 1 and then back to 0.
pushNotification.setApplicationIconBadgeNumber(1);
pushNotification.setApplicationIconBadgeNumber(0);
Rats, we never tried that.
We'll try today.
Thanks
@shaders
We thought we had tested this but we hadn't, so apologies for delay. Incompetence on our part.
We've set our code up to set the badges to 1 and then 0 but it will not clear the notifications from the drawer.
We've also put the second pushNotification.setApplicationIconBadgeNumber(0); in a setTimeout to trigger 500 millisecs after the first call to pushNotification.setApplicationIconBadgeNumber(1); and thats made no difference.
// This just clears the notifications from the drawer. It does NOT clear the notifications from the scheduled queue.
// For IOS we need to do clearall etc from the local notifications plugin.
function ClearIOSPushWooshAllNotificationsfromDrawer () {
var debugClearIOSPushWooshAllNotificationsfromDrawer = debugTrue;
if (pushNotification != undefined && pushNotification)
{
if (debugClearIOSPushWooshAllNotificationsfromDrawer)
ConsoleLog("ClearIOSPushWooshAllNotificationsfromDrawer: setting badge to one");
// We have to set the badge to 1 and then to 0 to clear stuff!
pushNotification.setApplicationIconBadgeNumber(1);
if (debugClearIOSPushWooshAllNotificationsfromDrawer)
ConsoleLog("ClearIOSPushWooshAllNotificationsfromDrawer: setting badge to zero");
setTimeout(function () {
pushNotification.setApplicationIconBadgeNumber(0);
} , 500);
if (debugClearIOSPushWooshAllNotificationsfromDrawer)
ShowNotificationQueue();
}
}
We can see the debug statements clearly but no matter what we call (with or without the timeout), we cannot get the drawer cleared.
Checking with debug level set higher, we can see the badges being set by PushWoosh
x
| Pushwoosh request:
| Url: https://A2EE0-23D28.api.pushwoosh.com/json/1.3/setBadge
| Payload: {"request":{"device_type":1,"badge":1,"application":"<<REDACTED>>","userId":"<<REDACTED>>","v":"4.1.8","hwid":"<<REDACTED>>"}}
| Status: "200 no error"
| Response: {"status_code":200,"status_message":"OK","response":null}
x
2016-11-21 10:21:13.264 Jambuster[6076:565020] [PW] [D] __34-[PWDataManagerCommon] setBadges completed
2016-11-21 10:21:13.425 Jambuster[6076:565020] ShowNotificationQueue: []
2016-11-21 10:21:13.650 Jambuster[6076:565020] [PW] [I] -[PWRequestManager]
x
| Pushwoosh request:
| Url: https://A2EE0-23D28.api.pushwoosh.com/json/1.3/setBadge
| Payload: {"request":{"device_type":1,"badge":0,"application":"<<REDACTED>>","userId":"<<REDACTED>>","v":"4.1.8","hwid":"<<REDACTED>>"}}
| Status: "200 no error"
| Response: {"status_code":200,"status_message":"OK","response":null}
x
This is very puzzling. Any suggestions please?
Thanks
Rob
Is pushNotification.cancelAllLocalNotifications() the right way to remove all local notifications in IOS?
Are we barking up the wrong tree with ?
pushNotification.setApplicationIconBadgeNumber(1);
pushNotification.setApplicationIconBadgeNumber(0);
Let me double check here and I'll come back to you
We've got to the bottom of this issue.
On IOS 8/9 pushNotification.cancelAllLocalNotifications()
works.
On IOS 10 pushNotification.cancelAllLocalNotifications()
doesn't work but
pushNotification.setApplicationIconBadgeNumber(1);
pushNotification.setApplicationIconBadgeNumber(0);
does work.
We tested this by terminating our app, sending a load of notifications down, checking they were in the Notification Drawer, starting our app up under Xcode and querying for the notifications to see if they were there and checking the drawer.
We now have a specific test case for this and have got around this by checking for device version and doing different clears in our code.
Our thoughts are that pushNotification.cancelAllLocalNotifications()
should be consistent across IOS version but we know that IOS10 changed the underlying notification framework.
At least we have got an understanding and workaround for this issue.
Rob
Closed by mistake
The behaviour of cancelAllLocalNotifications() has indeed changed since iOS10. Now it cancels only delivery of local notifications it does not remove already displayed notifications. Workaround for this was released in 6.4.1.
Thanks, does this mean that
pushNotification.cancelAllLocalNotifications()
works the same in ios 8.9 AND 10? So we can remove
pushNotification.setApplicationIconBadgeNumber(1);
pushNotification.setApplicationIconBadgeNumber(0);
from our IOS 10 specific code?
I read the release note and couldn't work out what it meant :)
It depends on what exactly you want to achieve.
pushNotification.cancelAllLocalNotifications()
Will remove all local notifications (both delivered and pending ones). Now it works the same in iOS 8-10.
pushNotification.setApplicationIconBadgeNumber(1);
pushNotification.setApplicationIconBadgeNumber(0);
Will remove all delivered local and remote notifications.
Thanks. That helps a lot.
We're trying to delete notifications from the IOS notification drawer using
and nothing is being deleted.
We can reproduce this by using the PushWoosh web app, sending down a test notification (whilst the app is either in the background OR is not running).
Once the notification is received, we try to remove it through catching the
onResume
event and then by sendingin our app.
We have also set up a local button in our app to test this directly and the alerts are not removed.
We can see that the event is being caught in Xcode
This used to work in old version (we think) but we can't easily go back and test.
Any suggestions?
Thanks
Rob
Versions Ios 8.5 and IOS 10.1.1 (We don't have an IOS 9.0 phone to hand) Pushwoosh 6.3.0 Cordova 6.4.0