Пример #1
0
        /// <summary>
        /// 初始化安卓通知实体
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        private static UMengPushModel AndroidModelInit(UMengSendMsgModel reqModel)
        {
            UMengPushModel androidModel = new UMengPushModel
            {
                appkey      = AppAndroidKey,
                description = reqModel.Description,
                payload     = new UMengPushAndroidContentModel
                {
                    display_type = UMengPushContentTypeEnum.notification.ToString(),
                    extra        = new ExtraBody(),
                    body         = new UMengPushAndroidBodyModel
                    {
                        ticker     = "WXQ在线",
                        title      = reqModel.Title,
                        text       = reqModel.Title,
                        after_open = reqModel.AfterOpen.ToString(),
                        activity   = reqModel.Activity,
                        url        = reqModel.Url,
                        custom     = reqModel.Custom
                    }
                }
            };

            return(androidModel);
        }
Пример #2
0
        /// <summary>
        /// 初始化IOS通知实体
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        private static UMengPushModel IOSModelInit(UMengSendMsgModel reqModel)
        {
            UMengPushModel iosModel = new UMengPushModel
            {
                appkey      = AppIosKey,
                description = reqModel.Description,
                payload     = new UMengPushIOSContentModel()
                {
                    aps = new UMengPushIOSApsModel
                    {
                        alert = new UMengPushIOSMsgModel
                        {
                            title = reqModel.Title
                                    //,body = reqModel.Text
                        }
                    },
                    ExtraData = new UMengPushIOSCustomData
                    {
                        Title = reqModel.
                                Title, Content = reqModel.Text
                    }
                }
            };

            return(iosModel);
        }
Пример #3
0
        /// <summary>
        /// 通过多个设备号发送ios推送
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        public static bool PushNotoficationByDeviceTokens(UMengSendMsgModel reqModel)
        {
            UMengPushModel iosModel = IOSModelInit(reqModel);

            UMengTools.InitPushModelByDeviceTokens(iosModel, reqModel.DeviceTokens, EquipmentTypeEnum.IOS);
            UMengResponseModel model = UMengTools.UMengPostRequest(UMengUrlList.ApiSend, EquipmentTypeEnum.IOS, iosModel);

            return(model != null && model.ret.Equals("SUCCESS"));
        }
Пример #4
0
        /// <summary>
        /// 通过多个用户发送ios推送
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        public static bool PushNotoficationByUsers(UMengSendMsgModel reqModel)
        {
            UMengPushModel iosModel = IOSModelInit(reqModel);

            UMengTools.InitPushModelByUsers(iosModel, reqModel.DeviceTokens, EquipmentTypeEnum.IOS);
            UMengResponseModel model = UMengTools.UMengPostRequest(UMengUrlList.ApiSend, EquipmentTypeEnum.IOS, iosModel);

            //2010:与alias对应的device_tokens为空
            //在单播的时候,如果安卓的用户推送给IOS设备,则会返回2010错误
            return(model != null && (model.ret.Equals("SUCCESS") || model.data.error_code == "2010"));
        }
Пример #5
0
 /// <summary>
 /// 推送通知(用户ID)
 /// </summary>
 /// <param name="reqModel"></param>
 /// <returns></returns>
 public static bool PushNotoficationByUsers(UMengSendMsgModel reqModel)
 {
     return(UMengAndroidPush.PushNotoficationByUsers(reqModel) && UMengIOSPush.PushNotoficationByUsers(reqModel));
 }