php - ios 通知未在 Kreait\Firebase 中接收
问题描述
所有的东西都在 android 上运行完美,但 ios 没有收到来自 php 后端 api 的任何消息。
案例 1:当应用程序处于后台模式时,从这里https://www.pushtry.com/测试时成功在移动应用程序上接收 PN 。
案例 2:下面的 php 脚本即使在后台模式应用程序中也不发送 PN。这是php api代码脚本。
use Kreait\Firebase\Factory;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
public function send_push($target_user_id)
{
$fcm_token = get_user_meta($target_user_id, 'fcm_token', true);
if (!empty($fcm_token)) {
$title = "Your Invitation Was Accepted";
$body = 'Click here to start game';
try {
$message = CloudMessage::withTarget('token', $fcm_token)
->withNotification(Notification::create($title, $body))
->withData([
'notification_type' => 'invitation_accepted',
'title' => $title,
'body' => "Your partner's accepted your invitation",
]);
$this->messaging->send($message);
} catch (\Throwable $e) {
// for PHP 7.x
$this->on_error($e);
} catch (\Exception $e) {
// for PHP 5.x
$this->on_error($e);
}
}
}
有人可以帮我指导ios :)
解决方案
推荐阅读
- php - Laravel 获取多个表
- google-apps-script - 如何在应用现有列的公式时快速向 Google 表格添加新行?
- mysql - MySQL中的分组索引
- roblox - Roblox Studio 如何循环检查玩家姓名是否正确输入到 texbox
- c++ - 在决定是通过参考还是价值传递时,尺寸真的是一个问题吗?
- python - .remove 函数不适用于“if”签入列表
- javascript - Matlab:绘制来自另一个脚本的数据
- serialization - Azure 服务总线消息反序列化在核心转换中中断
- sql-server - SQL Server:应用一对一匹配
- php - 如何限制获取的结果数量然后过滤它们?