NotificationPusher icon indicating copy to clipboard operation
NotificationPusher copied to clipboard

PushManager resends sent Pushes

Open red-led opened this issue 6 years ago • 3 comments

This code will send same message twice:

    ...
    $pushManager = new PushManager(PushManager::ENVIRONMENT_DEV);
    $push = new Push($gcmAdapter, $devices, $message);
    $pushManager->add($push);

    $pushManager->push();
    $pushManager->push();

Is it expected behavior or bug? PushManager can't be reused to send another batch of messages?

red-led avatar Dec 12 '18 12:12 red-led

This is an issue I also encountered where when you try to call $pushManager->push multiple times on one class initialization it will actually repeat a message to the users on the previous push and so on. Because a notification to a user might be different than a notification to another, I find myself initializing the class for every push notification I send. That fixes the multiplication of messages. I just wonder if there is a reset function you can call... I have not seen it thru the code

akkaweb avatar Jan 18 '19 19:01 akkaweb

@akkaweb feel free to add reset() method in PR

seyfer avatar Jan 20 '19 14:01 seyfer

@seyfer, Consider adding check if $push has been sent somewhere around here: https://github.com/Ph3nol/NotificationPusher/blob/master/src/Sly/NotificationPusher/PushManager.php#L89-L91

Maybe in next major version, cause it's backward incompatible.

red-led avatar Jan 20 '19 21:01 red-led