在 Kreait\Firebase 中未收到 ios 通知

问题描述

所有的东西都在 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 :)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)