iOS 10 Rich Media Push Notification (Media Attachment) in Objective-C

可紊 提交于 2019-11-28 06:02:43

your code is ok, it just expects a different push notification data format:

Try replacing this part:

// Create the payload body
$body['aps'] = array(
    'alert' => $message,
    'sound' => 'default',
     'mutable-content' => 1,
     'category'=> "pusher"
    );
$body['data'] = array(
    'mediaUrl' => "http://www.alphansotech.com/wp-content/uploads/2015/12/Push-notification-1.jpg",
    'mediaType' => "jpg"
);

with:

$body = array(
  'aps' => array(
    'alert' => 'Rich notification',
    'sound' => 'default',
    'mutable-content' => 1
  ),
  'mediaUrl'  => 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG',
  'mediaType' => 'image'
);

Please note, that image should be accessible via https://

Additional caveat for this not to work is having the Notification Service Deployment Target value that's not supported by your test device.

In my case the Notification Service template had automatically set its Deployment Target to 10.2 while my test device is 10.1

I wasted hours configuring my extension setup while its already working all along!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!