gpt4 book ai didi

ios - 带有 brozot/Laravel-FCM 的 laravel fcm 推送通知不适用于 ios,但在 android 上运行良好

转载 作者:行者123 更新时间:2023-12-01 15:28:51 27 4
gpt4 key购买 nike

即使 ios 也可以从 fcm 控制台获得通知。

Controller 功能 :

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" : []
}

最佳答案

如果您尝试使用 ios 模拟器,它将无法正常工作。您需要使用一些工具,例如 testflight 或真实设备进行测试。

我们可以在模拟器中检查推送通知吗?

关于ios - 带有 brozot/Laravel-FCM 的 laravel fcm 推送通知不适用于 ios,但在 android 上运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42292598/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com