Open 2Taps opened 7 years ago
Hey guys,
I found a way to make it work for now, hope it helps someone. I know is now the best way but it can make it until Rich or someone more experienced answer the issue. First i changed the config property use_multi_curl to false. Then your code can look like the sample bellow:
if($platform == 'gcm') { $pushResponses = $pushNotificationService->getResponses('rms_push_notifications.os.android.gcm'); $pushResponse = (isset($pushResponses[0])?$pushResponses[0]:''); if($pushResponse) { $pushResponseContent = $pushResponse->getContent(); if(strpos($pushResponseContent, 'NotRegistered') !== false) { //Remove the token from your database here } } }
@GuilhermeMoura1 Thanks for the snippet. With that one I came up to the following implementation for checking the response in general (not only for "NotRegistered"). This is just an action method in one of my controllers I have been using to test the push services (I just post this here in case of anyone is interested):
/**
* @Route("/push-test")
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function pushTestAction() {
// … use RMS here to send push notifications
// now get the response for android similar to the code above by GuilhermeMoura1
/** @var Response[] $pushResponses */
$pushResponses = $this->get('rms_push_notifications')->getResponses('rms_push_notifications.os.android.gcm');
$responses = [];
foreach ($pushResponses as $pushResponse) {
// this is a JSON string
$responseContent = $pushResponse->getContent();
// let's decode it
$responseData = json_decode($responseContent, true);
// add to list of responses
$responses[] = $responseData;
}
return $this->json([
'respones' => $responses,
]);
}
Hey guys,
I got push notification working with gcm but now i need to find the way to remove the DeviceToken/DeviceRegId from my database when for example the user uninstalled the app from his device.
In ios i am using the feedback service but i found nothing in the bundle docs about how to do this in android gcm, i also would like to know how to handle this with 'use_multi_curl' enabled.
In my parameters i have:
rms_push_notifications: android: timeout: 5 gcm: api_key: xxxxxxxx use_multi_curl: true dry_run: false
Thank you!