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;
 }
 public function startQueueMessage($devices, $data)
 {
     $deviceCollection = $this->generateDeviceCollection($devices);
     $devices = PushNotification::DeviceCollection($deviceCollection);
     $message = PushNotification::Message($data['message'], array('badge' => 1));
     Queue::push(function ($job) use($devices, $data) {
         //PushNotification::app('appNameIOS')
         //  ->to($devices)
         //  ->send($message);
         $message = '';
         foreach ($devices as $device) {
             $message .= 'sending message(' . $data['message'] . ') to ' . $device->token . ' : ';
         }
         File::append(app_path() . '/queue.txt', $message . PHP_EOL);
         $job->delete();
     });
 }
Esempio n. 3
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. 4
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. 5
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. 6
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. 7
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. 8
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));
 }