友盟推送消息踩坑及处理(PHP)

本文记录了使用友盟推送服务时遇到的问题及解决方案,主要涉及PHP环境。内容包括IOS自定义参数的正确传递方式(使用alert参数),以及针对MIUI、EMUI、Flyme系统设备离线转为系统下发报错的处理,通过修改UmengNotification.php文件添加特定字段来避免错误。
摘要由CSDN通过智能技术生成

公司的客户端的推送选用友盟推送,但是友盟的官方文档描述很少,对新手很不友好,所以特写此采坑纪录,废话不多说上代码。

公司业务只涉及单播和广播。所以只提供了单播和广播,业务拓展的话会补充其余部分。

消息推送代码:(页面加载文件均来自友盟代码包)

 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值