如何使用php中的推送通知将图像和文本消息发送到iphone


How to send Image and text messages to iphone using push notification in php

我知道向iPhone发送推送文本消息的代码,但我想向推送通知发送文本和图像。请引导我。

您可以发送一个与存储在数据库中的图像和文本消息相对应的唯一ID。

例如,在将唯一ID91ec59771e83caf010a84af28a15a506推送到您的iPhone应用程序后,该应用程序将转到链接

yoursite.com/ticket/91ec59771e83caf010a84af28a15a506

并下载您想要推送到应用程序的任何内容。

您不能发送图像。您可以在推送通知的有效负载中发送的字符数是有限的。

使用以下代码

$msg = array
          (
            "image"=> "http://www.androiddeft.com/wp-content/uploads/2017/11/Shared-Preferences-in-Android.png",
            'body'  => $message,
            'title' => 'New Notification from Scamper Skills',
            'receiver' => ucfirst($user_name),
            'icon'  => url('public/images/system/logo.png'),/*Default Icon*/
            'sound' => 'default',/*Default sound*/
            // 'type'=>$notifications['name'],
            // 'click_action' => $url,
          );
$headers = array(
                  'Authorization: key=' . $token,
                  'Content-Type: application/json'
                );