公司的客户端的推送选用友盟推送,但是友盟的官方文档描述很少,对新手很不友好,所以特写此采坑纪录,废话不多说上代码。
公司业务只涉及单播和广播。所以只提供了单播和广播,业务拓展的话会补充其余部分。
消息推送代码:(页面加载文件均来自友盟代码包)
1 <?php
2 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/android/AndroidBroadcast.php');
3 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/android/AndroidFilecast.php');
4 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/android/AndroidGroupcast.php');
5 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/android/AndroidUnicast.php');
6 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/android/AndroidCustomizedcast.php');
7 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/ios/IOSBroadcast.php');
8 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/ios/IOSFilecast.php');
9 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/ios/IOSGroupcast.php');
10 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/ios/IOSUnicast.php');
11 require_once(dirname(__FILE__) . '/' . 'umengmsg/notification/ios/IOSCustomizedcast.php');
12
13
14 class Be_Libs_UmengMsg {
15 protected static $appkey = '';
16 protected static $appMasterSecret = '';
17 protected static $validation_token = NULL;
18 protected static $device_tokens = '';
19
20 public static function __init($type) {
21 $configs = Be_Config::k('umeng.'.$type); //根据IOS/Android获取appkey和密钥
22 self::$appkey = $c