richsage / RMSPushNotificationsBundle

NOT MAINTAINED! ⛔️ Push notifications/messages for mobile devices. Supports iOS, Android (C2DM, GCM), Blackberry and Windows Mobile (toast only). A Symfony2 bundle.
MIT License
321 stars 152 forks source link

Handle GCM canonical IDs #83

Closed cajax closed 9 years ago

cajax commented 9 years ago

GCM server may respond with canonical ID to replace an outdated/expired registration ID sent in request. I think send() method should handle it and return.

http://developer.android.com/google/gcm/adv.html

richsage commented 9 years ago

thanks - PR welcome if you have time :-)

cajax commented 9 years ago

I am about to implement it. I'll try to make it nice and tidy before PR.

cajax commented 9 years ago

OK, looks like it isn't necessary since there is getResponses() method. This code should work:

$sent = $notificationsService->send($pushMessage);

$responses = $notificationsService->getResponses('rms_push_notifications.os.android.gcm');
foreach ($responses as $response) {
    $message = json_decode($response->getContent());
    if (!empty($message->registration_id)) {
        //update record in database
    }
}
richsage commented 9 years ago

that's fine - thanks for the update :-)