1. Go to this page and download the library: Download jgab-net/android-gcm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Route::filter('android.gcm',function($route, $request, $response){
/*verificamos que venga de una respuesta json (Response::json())
y que exista un registration_id en el input */
if($response instanceof \Illuminate\Http\JsonResponse
&& Input::has('registration_id')){
// Obtenemos el contenido de la respuesta
$content = json_decode($response->getContent());
AndroidGcm::addRegistrationId(Input::get('registration_id'), $content->user->id);
}
});
AndroidGcm::send($registrationIds,function($successRegistrationIds){
/*
Aquí puedes actualizar la bandera que indique que ya no debes
enviar la notificación a los dispositivos
Puedes usar $successRegistrationIds para valerte de esto.
*/
});