Esempio n. 1
0
 public static function message_push_notification($device_token)
 {
     $error_code = ApiResponse::OK;
     $devices = PushNotification::DeviceCollection(array(PushNotification::Device($device_token, array('badge' => 5))));
     $message = PushNotification::Message('This is message test', array('badge' => 1, 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
     $data = PushNotification::app('YineLover')->to($devices)->send($message);
     return $data;
 }
Esempio n. 2
0
 public function pushNotification(User $user, $message)
 {
     if ($user->device_token === null) {
         return;
     }
     // only support android notifications for now
     PushNotification::app('appNameAndroid')->to($user->device_token)->send($message);
 }
Esempio n. 3
0
 public function entregado()
 {
     $envios = Envios::find(Input::get('id'));
     $usuario = UsuariosHD::where('username', '=', Input::get('username'))->first();
     $pedido = Pedidos::where('id', '=', Input::get('id_pedido'))->first();
     $usuario->estatus_u = 'ocupado';
     $usuario->save();
     $reg = Input::get('reg_id');
     if ($reg != "") {
         $valor = PushNotification::Message('¡Tu pedido ha llegado!', array('valor' => 2, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
         PushNotification::app('Tasty')->to($reg)->send($valor);
     }
     $user = User::where('id', '=', $pedido->id_usuario)->first();
     $envios->estatus = 'entregado';
     $envios->save();
     return Response::json('success');
 }
 public function hogarPedidos()
 {
     $pedido = Pedidos::find(Input::get('idpedido'));
     $user = $usuario = User::where('id', '=', $pedido->id_usuario)->first();
     $restaurante = Restaurantes::where('id', '=', $pedido->id_restaurante);
     $var = Auth::user()->id_restaurante;
     $validacion = hd::where('id_restaurante', '=', $var)->get();
     if (Input::has('Confirmar')) {
         $pedido->estatus = 'sinPagar';
         $pedido->save();
         $envios = new Envios();
         $envios->estatus = 'pendiente';
         $envios->id_pedido = $pedido->id;
         $envios->coordenadas_accidente = 0;
         $envios->id_restaurante = $pedido->id_restaurante;
         $envios->save();
         foreach ($validacion as $key2 => $info2) {
             if ($info2->decision == 0) {
                 $reg = UsuariosHD::reg($var)->get();
                 if ($reg != "") {
                     foreach ($reg as $key => $info) {
                         $valor = PushNotification::Message('¡Envíos disponibles!', array('valor' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
                         PushNotification::app('HappyDelivery')->to($info->reg_id)->send($valor);
                     }
                 }
             }
             if ($info2->decision == 1) {
                 $reg = UsuariosHD::reg2($var)->get();
                 if ($reg != "") {
                     foreach ($reg as $key => $info) {
                         $valor = PushNotification::Message('¡Envíos disponibles!', array('valor' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
                         PushNotification::app('HappyDelivery')->to($info->reg_id)->send($valor);
                     }
                 }
             }
         }
         return Redirect::to('/')->with('success', 'Orden Aceptada Con Exito');
     } elseif (Input::has('Declinar')) {
         $pedido->estatus = 'declinada';
         $pedido->save();
         return Redirect::to('/')->with('success', 'Orden Cancelada Con Exito');
     }
 }
Esempio n. 5
0
 public function created($model)
 {
     if (Config::get('var.push', false)) {
         $dispositivos = Dispositivo::active()->eventos()->get();
         $disp = [];
         foreach ($dispositivos as $dispositivo) {
             $disp[] = PushNotification::Device($dispositivo->token);
         }
         $devices = PushNotification::DeviceCollection($disp);
         $actions = [];
         $actions[0] = new stdClass();
         $actions[0]->icon = 'eye';
         $actions[0]->title = 'ver';
         $actions[0]->callback = 'mycallback';
         $devices = PushNotification::DeviceCollection($disp);
         $message = PushNotification::Message($model->user->nombre . ' ha agregado un nuevo evento', ['badge' => 1, 'image' => 'www/logo.png', 'soundname' => 'alert', 'title' => 'Nueva Evento', "ledColor" => [0, 146, 234, 255], 'actions' => $actions]);
         $collection = PushNotification::app('android')->to($devices)->send($message);
     }
 }
Esempio n. 6
0
 public function push()
 {
     Notificacion::InsertarNotificacionesMasivas(Input::get('titulo'), Input::get('mensaje'));
     //Notificaciones en android
     $dispositivos = Dispositivo::active()->mensajes()->get();
     $disp = [];
     foreach ($dispositivos as $dispositivo) {
         $disp[] = PushNotification::Device($dispositivo->token);
     }
     $devices = PushNotification::DeviceCollection($disp);
     $message = PushNotification::Message(Input::get('mensaje'), ['badge' => 1, 'image' => 'www/logo.png', 'soundname' => 'alert', "ledColor" => [0, 146, 234, 255], 'title' => Input::get('titulo'), "style" => "inbox", "summaryText" => "Tienes %n% notificaciones", 'actions' => [["title" => "Abrir", "callback" => "abrir", "foreground" => false]]]);
     $collection = PushNotification::app('android')->to($devices)->send($message);
     // notificaciones en el navegador
     require_once 'vendor/autoload.php';
     Pushpad\Pushpad::$auth_token = '3f31ce907b0008fbde64d2f21399b9c7';
     Pushpad\Pushpad::$project_id = 1211;
     $notification = new Pushpad\Notification(array('body' => Input::get('mensaje', ''), 'title' => Input::get('titulo', 'Residencias Online')));
     $notification->broadcast(['tags' => []]);
     Session::flash('success', 'Mensaje enviado');
     return Redirect::back();
 }
Esempio n. 7
0
//         'badge' => 1,
//         'sound' => 'example.aiff',
//         'locArgs' => array(
//             'u1' => 3,
//             'u2' => 2,
//             'mid' => 7,
//         ),
//     ));
//     // send push
//     $send = PushNotification::app('appNameIOS')
//         ->to('84271d42284100e0e53c35f9cd2656bdbd2dc2afe8c0eb3dc83e786080d23878')
//         ->send($message);
//     /*$send = PushNotification::app('appNameIOS')
//     ->to('7d1195ae9b14d962dde3f383bdefb4cfafce2dfd4e57a308556647906d8860e0')
//     ->send(); */
//     dd($send);
//     if($send)
//         echo('Sent!');
//     else
//         echo('Not sent!');
// });
Route::get('testing-push-ios', function () {
    $send = PushNotification::app('appNameIOS')->to('75f7abe210345a4201efdb71c4351fd4cdd02f1077f6226eaf797bd35ef6d007')->send('Dummy push, from server');
    dd($send);
});
Route::get('testing-push-android', function () {
    $send = PushNotification::app('appNameAndroid')->to('APA91bH3PY1qGMsLIJ-lJMOETw3OZGbjBxhQM0BwKdNQZ_Ym1hSapbOmqpwBmOePZYaVF-AZVSZa8EluFdc1KXDWfebx2p50iRbshCcxyNjJoiNXnGqbZKuOZTfPB5Q9Rr3emw9shTGK')->send('Dummy push, from server');
    dd($send);
});
// Test S3 image upload
Route::post('api/test_s3_upload', array('uses' => 'ApiController@testS3Upload', 'as' => 'api.testS3Upload'));
Esempio n. 8
0
Route::resource('/crm/mail_setting', 'MailSettingController');
Route::resource('/crm/permission_pos_type', 'PermPosTypeSettingController');
Route::resource('/crm/system_icon', 'SystemIconController');
// Post Routes ------------------------------------------------------------------------------------->
Route::resource('/crm/post', 'PostController');
// Notification Routes ------------------------------------------------------------------------------------->
Route::resource('/crm/notification', 'NotificationController');
// API Routes Start ------------------------------------------------------------------------------------->
Route::group(array('prefix' => '/api/v1'), function () {
    Route::post('login', 'Api\\v1\\LoginApiController@login');
    Route::post('get_posts', 'Api\\v1\\PostApiController@getPosts');
    Route::post('get_post', 'Api\\v1\\PostApiController@getPost');
    Route::post('new_post', 'Api\\v1\\PostApiController@newPost');
    Route::post('like_post', 'Api\\v1\\PostApiController@likePost');
    Route::post('unlike_post', 'Api\\v1\\PostApiController@unlikePost');
    Route::post('get_notifications', 'Api\\v1\\NotificationApiController@getNotifications');
    Route::post('post_comment', 'Api\\v1\\CommentApiController@postComment');
    Route::post('get_comments', 'Api\\v1\\CommentApiController@getComments');
});
// API Routes End ------------------------------------------------------------------------------------->
/*Start Test Routes*/
Route::post('/test/pns', function () {
    $deviceToken = Input::get('device_token');
    PushNotification::app('l5fAndroid')->to($deviceToken)->send('Hello World, i`m a push message');
});
Route::post('/test/artisan', function (Request $request) {
    $command = $request->get('command');
    $exitCode = Artisan::call($command, ['--force' => true]);
    return $exitCode;
});
/*End Test Routes*/
Esempio n. 9
0
 public function timevaloracion()
 {
     $reg = Input::get('reg_id');
     if ($reg != "") {
         $valor = PushNotification::Message('¡Valora tu pedido!', array('valor' => 1, 'sound' => 'example.aiff', 'actionLocKey' => 'Action button title!', 'locKey' => 'localized key', 'locArgs' => array('localized args', 'localized args'), 'launchImage' => 'image.jpg', 'custom' => array('custom data' => array('we' => 'want', 'send to app'))));
         PushNotification::app('Tasty')->to($reg)->send($valor);
     }
     return Response::json('1');
 }
 public function getSendMessage($device_token = null, $message = null)
 {
     PushNotification::app('featherqAndroid')->to($device_token)->send($message);
 }
Esempio n. 11
0
 public function pushWord($word)
 {
     $word = WordCard::find($word['word_id']);
     DB::table('users')->where('word_id', 0)->update(['word_id' => Setting::first()->word_id]);
     User::where('device', '<>', '')->groupBy('device')->chunk(200, function ($users) use($word) {
         $devices = PushNotification::DeviceCollection($users->map(function ($user) {
             $this->line($user->device);
             return PushNotification::Device($user->device, ['badge' => 1]);
         })->toArray());
         //            foreach ($users as $user) {
         //                $rawdevices[] = PushNotification::Device($user->device, ['badge' => 1]);
         //            }
         //            $devices = PushNotification::DeviceCollection($rawdevices);
         $this->line('Sending chunk of 200...');
         try {
             PushNotification::app('IOS')->to($devices)->send($word->word . " - новое слово для изучения", ["custom" => ["cdata" => [["word_id" => $word->id, "cat_id" => $word->category_id]], "type" => 0]]);
         } catch (Exception $e) {
             $this->error($e);
         }
     });
     $this->info('Dayword ' . $word->word . '(' . $word->id . ') category ' . $word->category_id . ' pushed.');
 }
Esempio n. 12
0
 public function cargarCobros()
 {
     $mes = Input::get('mes');
     $año = Input::get('año');
     foreach (Residencias::all() as $residencia) {
         $solvencia = Solvencia::firstorNew(['mes' => $mes, 'año' => $año, 'residencia_id' => $residencia->id]);
         $solvencia->estado = 3;
         $solvencia->monto = getdeuda($residencia->id, $mes, $año);
         $solvencia->save();
     }
     Notificacion::InsertarNotificacionesMasivas("Nuevo Recibo Agregado", "Se ha agregado el recibo de " . getMeses()[$mes] . $año);
     Session::flash('success', "Cobros cargados Correctamente");
     if (Config::get('var.push', false)) {
         $dispositivos = Dispositivo::active()->mensajes()->get();
         $disp = [];
         foreach ($dispositivos as $dispositivo) {
             $disp[] = PushNotification::Device($dispositivo->token);
         }
         $devices = PushNotification::DeviceCollection($disp);
         $message = PushNotification::Message("Se ha agregado el recibo de " . getMeses()[$mes] . $año, ['badge' => 1, 'image' => 'www/logo.png', 'soundname' => 'alert', "ledColor" => [0, 146, 234, 255], 'title' => 'Nueva Recibo Agregado']);
         $collection = PushNotification::app('android')->to($devices)->send($message);
     }
     return Redirect::to('admin/Finanzas/gestion?mes=' . $mes . '&año=' . $año);
 }
Esempio n. 13
0
 public static function sendPnsToIOSDevices($device_tokens, $message, $data = null)
 {
     try {
         $i_devices_collection = array();
         foreach ($device_tokens as $device_token) {
             $i_devices_collection[] = \PushNotification::Device($device_token);
         }
         if ($i_devices_collection) {
             $i_devices_collection = \PushNotification::DeviceCollection($i_devices_collection);
             if ($data && is_array($data)) {
                 $message = \PushNotification::Message($message, $data);
             }
             \PushNotification::app(self::$pns_ios_app_name)->to($i_devices_collection)->send($message);
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Esempio n. 14
0
 public function pushWords($words)
 {
     function implode_r($glue, array $arr)
     {
         $ret = '';
         foreach ($arr as $piece) {
             if (is_array($piece)) {
                 $ret .= '; ' . implode_r($glue, $piece);
             } else {
                 $ret .= $glue . $piece;
             }
         }
         return $ret;
     }
     $users = User::where('device', '<>', '')->with('subscriptions')->get();
     $rawdevices = $users->filter(function ($user) {
         return $user->subscriptions->count() > 0;
     })->map(function ($user) {
         return PushNotification::Device($user->device, ['badge' => 1]);
     });
     dd($rawdevices->toArray());
     $devices = PushNotification::DeviceCollection($rawdevices);
     PushNotification::app('IOS')->to($devices)->send("Пора знакомится с новыми словами", ["custom" => ["cdata" => $words, "type" => 1]]);
     $this->info('Pushed wordcards');
     $this->info(implode_r(', ', $words));
 }