laravel fcm push notification with brozot/Laravel-FCM not working on ios but working fine with android

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

Even ios can get notification from fcm console.

Controller function:

public function push(Request $request) {     $validator = Validator::make($request->all(), [         'title' = > 'required',             'body' = > 'required',             'token' = > 'required',             'type' = > 'required',             'id' = > 'required',      ]);      if ($validator->fails()) {         $this->throwValidationException(             $request, $validator         );     }      $title = $request['title'];     $body = $request['body'];     $type = $request['type'];     $id = $request['id'];     $dataarray = array(         "id" = >$id,         "type" = >$type,         'title' = >$title,         'body' = >$body,         'image' = >'321451_v2.jpg',     );      $token = $request['token'];      return $push = Push::sendpush($title, $body, $dataarray, $token);  }  push model function : public static function sendpush($title, $body, $dataarray, $token) {       $optionBuiler = new OptionsBuilder();     $optionBuiler->setTimeToLive(60 * 20);      $notificationBuilder = new PayloadNotificationBuilder($title);     $notificationBuilder->setBody($body)         ->setSound('');      $dataBuilder = new PayloadDataBuilder();     $dataBuilder->addData($dataarray);      $option = $optionBuiler->build();     $notification = $notificationBuilder->build();     $data = $dataBuilder->build();      $token = $token;      $downstreamResponse = FCM::sendTo($token, $option, $notification, $data);      return new JsonResponse(array('status' = >'1', 'sucess' = >$downstreamResponse->numberSuccess(), 'fail' = > $downstreamResponse->numberFailure(), 'msg' = >$downstreamResponse->tokensWithError()), 200);  }  Response: {     "status": "1",     "sucess" : 0,     "fail" : 1,     "msg" : [] } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!