gomoob / php-pushwoosh

A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.
http://gomoob.github.io/php-pushwoosh
MIT License
65 stars 37 forks source link

CreateMessageResponse does not pass along UnknownDevices #64

Open curtisgibby opened 7 years ago

curtisgibby commented 7 years ago

Pushwoosh now includes in its raw createMessage response a list of devices/tokens for which it does not know what they are (likely because the user removed the app or the token was renewed.) This is similar to the bulk /getunregistereddevices call, but applies to each message in the moment as you try to send it. See example output $json from CreateMessageResponse::create below:

Array
(
    [status_code] => 200
    [status_message] => OK
    [response] => Array
        (
            [Messages] => Array
                (
                    [0] => CODE_NOT_AVAILABLE
                )

            [UnknownDevices] => Array
                (
                    [] => Array
                        (
                            [0] => 0017a2859e0cc1d37bdfc83cf3e92a8bb47f6405b213516eba76082562d3a646
                        )

                )

        )

)

It would be helpful if CreateMessageResponse could pass these unknown devices back up the chain to userland code to allow me to remove my records of those bad tokens. A method similar to the existing setMessages would be nice, something like setUnknownDevices:

// If 'UnknownDevices' are provided
if (array_key_exists('UnknownDevices', $json['response'])) {
    $createMessageResponseResponse->setUnknownDevices($json['response']['UnknownDevices']);
}