public function actionSendNotification()
 {
     $request = Yii::app()->request;
     try {
         $message = StringHelper::filterString($request->getPost('message'));
         $device_id = StringHelper::filterString($request->getPost('device_id'));
         $result = GcmHelper::sendNotification($device_id, $message);
         ResponseHelper::JsonReturnSuccess($result, 'success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
예제 #2
0
파일: Util.php 프로젝트: huynt57/medlatec
 public static function sendNotificationBasedOnStatus($device_token, $status, $message)
 {
     $token = DeviceTk::model()->findByAttributes(array('device_token' => $device_token));
     if ($token) {
         $time_diff = time() - $token->updated_at;
         // echo $time_diff; die;
         if ($time_diff < 7776000) {
             if ($status == 2 || $status == 4) {
                 //  echo '2'; die;
                 if ($token->platform == 'android') {
                     GcmHelper::sendNotification($device_token, $message['message_android']);
                 } else {
                     if ($token->platform == 'ios') {
                         // echo $device_token; die;
                         IosPushHelper::sendNotification($device_token, $message['message_ios']);
                     }
                 }
             }
         }
     }
 }