如何推送通知发送到多个设备? [英] How to send Push Notification to multiple devices?

查看:126
本文介绍了如何推送通知发送到多个设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次使用推送通知我App.I已经通过示例应用程序的书籍一起走了,我如何推送通知发送到单个device.But我没有得到我应该怎么做改变在我的程序推送通知发送到多个devices.I我使用'PushMeBaby服务器端编码申请。
请帮帮我。
先谢谢了。

This is the first time I am using push notification in my App.I have gone through sample applications along with books and I got how to send push notification to a single device.But I am not getting exactly what changes should I do in my program to send push notification to multiple devices.I am using 'PushMeBaby' application for server side coding. Please,Help me out. Thanks in Advance.

推荐答案

试试这个例子code和修改您的环境。

Try this example code and modify for your environment.

    $apnsHost = '<APNS host>';
    $apnsPort = <port num>;
    $apnsCert = '<cert>';

    $streamContext = stream_context_create();
    stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

    $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);

    $payload['aps'] = array('alert' => 'some notification', 'badge' => 0, 'sound' => 'none');
    $payload = json_encode($payload);

// Note: $device_tokens_array has list of 5 devices' tokens

    for($i=0; $i<5; $i++)
    {
            $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device_tokens_array[i])) . chr(0) . chr(strlen($payload)) . $payload;

            fwrite($apns, $apnsMessage);
    }?>

本文将帮助验证点连接和连接状态:<一href=\"http://stackoverflow.com/questions/2583957/apple-push-notification-sending-high-volumes-of-messages\">Apple推送通知:发送信息的大容量

其他参考链接:

<一个href=\"http://stackoverflow.com/questions/5050363/how-can-i-send-push-notification-to-multiple-devices-in-one-go-in-iphone\">How我可以发送推送通知到多个设备一气呵成的iPhone?

<一href=\"http://stackoverflow.com/questions/1642182/how-to-handle-multiple-devices-when-using-push-notification\">how使用推送通知时,处理多个设备?

这篇关于如何推送通知发送到多个设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆