PHP code example of jgab-net / android-gcm

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/ */

    

jgab-net / android-gcm example snippets



return array(
    'api_key' => 'aquí el api_key'
);



AndroidGcm::addRegistrationId($registration_id, $user_id);



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);
    }
});



Route::post('auth',  array('after' => 'android.gcm', 'uses' => 'Vendor\Paquete\Controller@method'));
 


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.
    */
});



AndroidGcm::send($registrationIds,function($successRegistrationIds) use($otherValue1,$otherValue2){  

    /*
      
    */
});



AndroidGcm::getApiResponse()

shell

php artisan config:publish jgab-net/android-gcm
shell

php artisan migrate --package=jgab-net/android-gcm