Ph3nol / NotificationPusher

Standalone PHP library for easy devices notifications push.
MIT License
1.18k stars 273 forks source link

PushManager resends sent Pushes #178

Open red-led opened 5 years ago

red-led commented 5 years ago

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?

akkaweb commented 5 years ago

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

seyfer commented 5 years ago

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

red-led commented 5 years ago

@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.