Ejemplo n.º 1
0
        // Token: 0x060004A6 RID: 1190 RVA: 0x00009978 File Offset: 0x00007B78
        public string add(SingleMessage message, igetui.Target target)
        {
            if (seqId >= 5000)
            {
                throw new Exception("Can not add over 5000 message once! Please call submit() first.");
            }
            string          data = createPostParams(message, target);
            SingleBatchItem item = SingleBatchItem.CreateBuilder().SetSeqId(seqId).SetData(data).Build();

            innerMsgList.Add(item);
            seqId++;
            return(string.Concat(seqId) ?? "");
        }
Ejemplo n.º 2
0
 // Token: 0x060004A7 RID: 1191 RVA: 0x000099F8 File Offset: 0x00007BF8
 public string createPostParams(SingleMessage message, igetui.Target target)
 {
     return(JsonConvert.SerializeObject(new Dictionary <string, object>
     {
         {
             "action",
             "pushMessageToSingleAction"
         },
         {
             "appkey",
             APPKEY
         },
         {
             "clientData",
             Convert.ToBase64String(message.Data.getTransparent().ToByteArray())
         },
         {
             "transmissionContent",
             message.Data.getTransmissionContent()
         },
         {
             "isOffline",
             message.IsOffline
         },
         {
             "offlineExpireTime",
             message.OfflineExpireTime
         },
         {
             "appId",
             target.appId
         },
         {
             "clientId",
             target.clientId
         },
         {
             "type",
             2
         },
         {
             "pushType",
             message.Data.getPushType()
         },
         {
             "version",
             "3.0.0.0"
         }
     }));
 }
Ejemplo n.º 3
0
        //PushMessageToList接口测试代码
        public static void PushMessageToList(int PaltForm, string clientId, string NoticeTitle, string NoticeContent, string custom_content)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            ListMessage message = new ListMessage();

            /*消息模版:
             *   1.TransmissionTemplate:透传功能模板
             *   2.LinkTemplate:通知打开链接功能模板
             *   3.NotificationTemplate:通知透传功能模板
             *   4.NotyPopLoadTemplate:通知弹框下载功能模板
             */

            //TransmissionTemplate template =  TransmissionTemplateDemo();
            //NotificationTemplate template =  NotificationTemplateDemo();
            //LinkTemplate template = LinkTemplateDemo();
            NotyPopLoadTemplate template = NotyPopLoadTemplateDemo();

            message.IsOffline         = false;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;      // 离线有效时间,单位为毫秒,可选
            message.Data = template;

            //设置接收者
            List <com.igetui.api.openservice.igetui.Target> targetList = new List <com.igetui.api.openservice.igetui.Target>();

            com.igetui.api.openservice.igetui.Target target1 = new com.igetui.api.openservice.igetui.Target();
            target1.appId    = APPID;
            target1.clientId = CLIENTID;

            // 如需要,可以设置多个接收者
            //com.igetui.api.openservice.igetui.Target target2 = new com.igetui.api.openservice.igetui.Target();
            //target2.AppId = APPID;
            //target2.ClientId = "ddf730f6cabfa02ebabf06e0c7fc8da0";

            targetList.Add(target1);
            //targetList.Add(target2);

            String contentId  = push.getContentId(message);
            String pushResult = push.pushMessageToList(contentId, targetList);

            System.Console.WriteLine("-----------------------------------------------");
            System.Console.WriteLine("服务端返回结果:" + pushResult);
        }
Ejemplo n.º 4
0
        private static string PushMessageToSingle(string clientID)
        {
            // 推送主类
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
            //  LinkTemplate template = LinkTemplateDemo(strAdvice); 
            TransmissionTemplate transmissionTemplate = TransmissionTemplateDemo();
            SingleMessage message = new SingleMessage();
            // 用户当前不在线时,是否离线存储,可选
            message.IsOffline = false;
            // 离线有效时间,单位为毫秒,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = transmissionTemplate;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId = APPID;
            target.clientId = clientID;
            String pushResult = push.pushMessageToSingle(message, target);
            return pushResult;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 18.个推-工作交办 todolist(群组日程、待办)消息通知(刘静杰)
        /// </summary>
        /// <param name="deviceid"></param>
        /// <param name="touid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static async Task PushToDoMessage(string deviceid, string touid, ScheduleModel msg)
        {
            var     currentMethod = "PushToDoMessage";
            IGtPush push          = new IGtPush(HOST, APPKEY, MASTERSECRET);
            var     intent        = $"intent:#Intent;component=net.cnki.okms/.pages.base.BootActivity;end";
            var     title         = "待办任务";
            var     content       = msg.title;

            var getui = new GeTuiMessage
            {
                mtype    = 18,
                mcontent = msg,
            };
            TransmissionTemplate template = TransmissionTemplate(title, content, intent, JsonConvert.SerializeObject(getui));

            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
            message.Data = template;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = deviceid;

            var messageJson = JsonConvert.SerializeObject(message);

            LoggerHelper.AndroidPush($"1.(个推-待办任务)给[{touid}]推送的内容:" + messageJson);

            try
            {
                String pushResult = push.pushMessageToSingle(message, target);
                LoggerHelper.AndroidPush($"2.(个推-待办任务)给[{touid}]返回结果:" + pushResult);
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                LoggerHelper.AndroidPush($"3.(个推-待办任务)给[{touid}]发生了异常,重发后,服务端返回结果:----------------" + pushResult);
            }
        }
Ejemplo n.º 6
0
        //IOS推送
        public static void PushTCMessageToList(string title, string text, string transmissioncontent, string iconUrl, List <string> pushChannels)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            ListMessage message = new ListMessage();

            /*消息模版:
             *   1.TransmissionTemplate:透传功能模板
             *   2.LinkTemplate:通知打开链接功能模板
             *   3.NotificationTemplate:通知透传功能模板
             *   4.NotyPopLoadTemplate:通知弹框下载功能模板
             */

            TransmissionTemplate template = TransmissionTemplateDemo(title, text, transmissioncontent, iconUrl, pushChannels);

            template.TransmissionContent = transmissioncontent;

            message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
            message.Data = template;
            //message.PushNetWorkType = 0;             //判断是否客户端是否wifi环境下推送,1为在WIFI环境下,0为非WIFI环境

            //设置接收者
            List <com.igetui.api.openservice.igetui.Target> targetList = new List <com.igetui.api.openservice.igetui.Target>();

            for (int i = 0; i < pushChannels.Count; i++)
            {
                string clientId = pushChannels[i];
                if (!string.IsNullOrEmpty(clientId))
                {
                    // 如需要,可以设置多个接收者
                    com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
                    target.appId    = APPID;
                    target.clientId = clientId;
                    //target1.alias = ALIAS;
                    targetList.Add(target);
                }
            }

            String contentId  = push.getContentId(message, "msgpush");
            String pushResult = push.pushMessageToList(contentId, targetList);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 14  -->>   新建直播的通知(申志云)
        /// </summary>
        /// <param name="deviceid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static async Task PushLiveAPPInfoNotice(string deviceid, string touid, string msg)
        {
            var currentMethod = "PushLiveAPPInfoNotice";
            var title         = "新建直播通知";
            var content       = "新建直播";
            var model         = JsonConvert.DeserializeObject <LiveAPPInfo>(msg);

            title = model.Name;
            IGtPush push   = new IGtPush(HOST, APPKEY, MASTERSECRET);
            var     intent = $"intent:#Intent;component=net.cnki.okms/.pages.base.BootActivity;end";
            var     getui  = new GeTuiMessage
            {
                mtype    = 14,
                mcontent = model,
            };
            TransmissionTemplate template = TransmissionTemplate(title, content, intent, JsonConvert.SerializeObject(getui));
            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = template;
            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = deviceid;
            var messageJson = JsonConvert.SerializeObject(message);

            LoggerHelper.AndroidPush($"1.个推-新建直播类消息[{touid}]推送的消息内容为:{Environment.NewLine}{messageJson}");
            try
            {
                String pushResult = push.pushMessageToSingle(message, target);
                LoggerHelper.AndroidPush($"2.个推-新建直播类消息[{touid}]推送的返回结果:{Environment.NewLine}{pushResult}");
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                LoggerHelper.AndroidPush($"3.个推-新建直播类消息[{touid}]发生了异常,重发后,服务端返回结果:----------------" + pushResult);
            }
        }
Ejemplo n.º 8
0
        public static void bindAliasAll()
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
            List <com.igetui.api.openservice.igetui.Target> Lcids = new List <com.igetui.api.openservice.igetui.Target>();

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.clientId = CLIENTID;
            target.alias    = ALIAS;

            com.igetui.api.openservice.igetui.Target target1 = new com.igetui.api.openservice.igetui.Target();
            target1.clientId = "7c6edf411568c5db12e565425e4a381633";
            target1.alias    = ALIAS1;


            Lcids.Add(target);
            Lcids.Add(target1);

            String ret = push.bindAlias(APPID, Lcids);

            System.Console.WriteLine(ret);
        }
Ejemplo n.º 9
0
        public void PushMessageToSingle()
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            //消息模版:TransmissionTemplate:透传模板

            NotificationTemplate template = NotificationTemplateDemo();


            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
            message.Data = template;
            //判断是否客户端是否wifi环境下推送,2为4G/3G/2G,1为在WIFI环境下,0为不限制环境
            //message.PushNetWorkType = 1;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = CLIENTID;
            //target.alias = ALIAS;
            try
            {
                String pushResult = push.pushMessageToSingle(message, target);

                System.Console.WriteLine("-----------------------------------------------");
                System.Console.WriteLine("-----------------------------------------------");
                System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                System.Console.WriteLine("-----------------------------------------------");
                System.Console.WriteLine("-----------------------------------------------");
                System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
            }
        }
Ejemplo n.º 10
0
 public void PushMessageToSingle(string ClientID, string AppID, string AppKey, string MasterSecret)
 {
     try
     {
         IGtPush push = new IGtPush(HOST, AppKey, MasterSecret);
         NotificationTemplate template = NotificationTemplateDemo(AppID, AppKey);
         SingleMessage        message  = new SingleMessage();
         message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
         message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
         message.Data = template;
         //判断是否客户端是否wifi环境下推送,2为4G/3G/2G,1为在WIFI环境下,0为不限制环境
         message.PushNetWorkType = 0;
         com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
         target.appId    = AppID;
         target.clientId = ClientID;
         try
         {
             String pushResult = push.pushMessageToSingle(message, target);
             // System.Console.WriteLine("-----------------------------------------------");
             // System.Console.WriteLine("-----------------------------------------------");
             // System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
             Utils.log("----------------服务端返回结果:" + ClientID + "----" + pushResult);
         }
         catch (RequestException e)
         {
             String requestId = e.RequestId;
             //发送失败后的重发
             String pushResult = push.pushMessageToSingle(message, target, requestId);
             // System.Console.WriteLine("-----------------------------------------------3");
             // System.Console.WriteLine("-----------------------------------------------");
             // System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
         }
     }
     catch (Exception ex)
     {
         Utils.log("PushMessageToSingle Error:" + ex.Message);
     }
 }
        //PushMessageToList接口测试代码
        /// <summary>
        /// 对指定列表用户推送
        /// </summary>
        private static void PushMessageToList()
        {
            // 推送主类(方式1,不可与方式2共存)
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
            // 推送主类(方式2,不可与方式1共存)此方式可通过获取服务端地址列表判断最快域名后进行消息推送,每10分钟检查一次最快域名
            //IGtPush push = new IGtPush("",APPKEY,MASTERSECRET);
            ListMessage message = new ListMessage();

            LinkTemplate template = LinkTemplateDemo();

            // 用户当前不在线时,是否离线存储,可选
            message.IsOffline = true;
            // 离线有效时间,单位为毫秒,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data            = template;
            message.PushNetWorkType = 0;        //判断是否客户端是否wifi环境下推送,1为在WIFI环境下,0为不限制网络环境。
            //设置接收者
            List <com.igetui.api.openservice.igetui.Target> targetList = new List <com.igetui.api.openservice.igetui.Target>();

            com.igetui.api.openservice.igetui.Target target1 = new com.igetui.api.openservice.igetui.Target();
            target1.appId    = APPID;
            target1.clientId = CLIENTID;

            // 如需要,可以设置多个接收者
            //com.igetui.api.openservice.igetui.Target target2 = new com.igetui.api.openservice.igetui.Target();
            //target2.AppId = APPID;
            //target2.ClientId = "ddf730f6cabfa02ebabf06e0c7fc8da0";

            targetList.Add(target1);
            //targetList.Add(target2);

            String contentId  = push.getContentId(message);
            String pushResult = push.pushMessageToList(contentId, targetList);

            System.Console.WriteLine("-----------------------------------------------");
            System.Console.WriteLine("服务端返回结果:" + pushResult);
        }
        private static String DeviceToken = "";  //填写IOS系统的DeviceToken
        /// <summary>
        /// 对单个用户的推送
        /// </summary>
        /// <returns></returns>
        public static string PushMessageToSingle()
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
            //消息模版:网页模板
            LinkTemplate template = LinkTemplateDemo();
            // 单推消息模型
            SingleMessage message = new SingleMessage();

            // 用户当前不在线时,是否离线存储,可选
            message.IsOffline = true;
            // 离线有效时间,单位为毫秒,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = template;
            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = CLIENTID;
            //target.alias = ALIAS;
            try
            {
                string pushResult = push.pushMessageToSingle(message, target);
                return("发送成功" + pushResult);
                //System.Console.WriteLine("-----------------------------------------------");
                //System.Console.WriteLine("-----------------------------------------------");
                //System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
            }
            catch (RequestException e)
            {
                string requestId = e.RequestId;

                //发送失败后的重发
                string pushResult = push.pushMessageToSingle(message, target, requestId);
                return("失败重发" + pushResult);
                //System.Console.WriteLine("-----------------------------------------------");
                //System.Console.WriteLine("-----------------------------------------------");
                //System.Console.WriteLine("----------------服务端返回结果:" + pushResult);
            }
        }
Ejemplo n.º 13
0
        private string PushMessageToListIOS(RequestPushMessageToList req)
        {
            try
            {
                IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

                ListMessage message = new ListMessage();

                TransmissionTemplate template = TransmissionTemplateIOS(req.Title);

                message.IsOffline = true;                         // 用户当前不在线时,是否离线存储,可选
                message.OfflineExpireTime = 1000 * 3600 * 12;            // 离线有效时间,单位为毫秒,可选
                message.Data = template;

                //设置接收者
                var targetList = new List<com.igetui.api.openservice.igetui.Target>();
                string[] cds = req.Clientids.Split(",".ToCharArray());

                foreach (string s in cds)
                {
                    var target1 = new com.igetui.api.openservice.igetui.Target();
                    target1.appId = APPID;
                    target1.clientId = s;
                    targetList.Add(target1);
                }

                String contentId = push.getContentId(message);
                String pushResult = push.pushMessageToList(contentId, targetList);

                return pushResult;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 15  -->>   自建群编辑通知(刘静杰)
        /// </summary>
        /// <param name="deviceid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static async Task PushSelfGroupNoticeMore(string deviceid, string touid, SelfGroupNoticeMore model)
        {
            var currentMethod = "PushSelfGroupNoticeMore";
            var title         = "群组动态通知";
            var content       = "群组动态";

            title = model.groupname;
            if (model.type == 0)
            {
                content = model.membername + "新加入群组";
            }
            else if (model.type == 1)
            {
                content = model.membername + "已被移出群组";
            }
            else if (model.type == 2)
            {
                content = model.membername + "退出群组";
            }
            else if (model.type == 3)
            {
                content = "群组已经被解散";
            }
            else if (model.type == 4)
            {
                content = "修改群组信息动态";
            }

            IGtPush push   = new IGtPush(HOST, APPKEY, MASTERSECRET);
            var     intent = $"intent:#Intent;component=net.cnki.okms/.pages.base.BootActivity;end";
            var     getui  = new GeTuiMessage
            {
                mtype    = 15,
                mcontent = model,
            };
            TransmissionTemplate template = TransmissionTemplate(title, content, intent, JsonConvert.SerializeObject(getui));
            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = template;
            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = deviceid;
            var messageJson = JsonConvert.SerializeObject(message);

            LoggerHelper.AndroidPush($"1.个推-自建群编辑通知类消息[{touid}]推送的消息内容为:{Environment.NewLine}{messageJson}");
            try
            {
                String pushResult = push.pushMessageToSingle(message, target);
                LoggerHelper.AndroidPush($"2.个推-自建群编辑通知类消息[{touid}]推送的返回结果:{Environment.NewLine}{pushResult}");
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                LoggerHelper.AndroidPush($"3.个推-自建群编辑通知类消息[{touid}]发生了异常,重发后,服务端返回结果:----------------" + pushResult);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 1.个推-聊天消息
        /// </summary>
        /// <param name="deviceid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static async Task PushMessageToSingle(string touid, string deviceid, Msg msg)
        {
            var currentMethod = "PushMessageToSingle";
            //LoggerHelper.AndroidPush($"0.开始给[{touid}]推送Android消息{Environment.NewLine},cliendid={deviceid}");
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            //消息模版:TransmissionTemplate:透传模板
            //var intent = $"intent:#Intent;component=net.cnki.okms/.pages.base.BootActivity;end";
            var intent         = $"intent:#Intent;component=net.cnki.okms/.pages.base.IndexActivity;S.friendId={msg.fromuid};S.friendName={msg.fromrealname};S.isGroup=0;S.levelNoticeTpye=1;end";
            var title          = msg.fromrealname;
            var content        = "";
            var fromPersonName = "";

            if (msg.isgroup == 1)
            {
                title          = msg.torealname;
                fromPersonName = msg.fromrealname + ":";
            }
            content = fromPersonName + msg.msg;
            if (msg.msgtype == 1)
            {
                content = fromPersonName + "[图片]";
            }
            else if (msg.msgtype == 2)
            {
                content = fromPersonName + "[文件]";
            }
            else if (msg.msgtype == 4)
            {
                content = fromPersonName + "[语音]";
            }
            else if (msg.msgtype == 5)
            {
                content = fromPersonName + "[地图签到]";
            }
            else if (msg.msgtype == 3)
            {
                content = fromPersonName + "[图片]";
            }

            var getui = new GeTuiMessage
            {
                mtype    = 1,
                mcontent = msg,
            };

            if (msg.isgroup == 1)
            {
                intent = $"intent:#Intent;component=net.cnki.okms/.pages.base.IndexActivity;S.friendId={msg.touid};S.friendName={msg.torealname};S.isGroup=1;S.levelNoticeTpye=1;end";
                //template = TransmissionTemplate(msg.torealname, msg.msg, intent, JsonConvert.SerializeObject(msg));
            }
            TransmissionTemplate template = TransmissionTemplate(title, content, intent, JsonConvert.SerializeObject(getui));



            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
            message.Data = template;
            //判断是否客户端是否wifi环境下推送,2为4G/3G/2G,1为在WIFI环境下,0为不限制环境
            //message.PushNetWorkType = 1;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = deviceid;
            //target.alias = ALIAS;

            var messageJson = JsonConvert.SerializeObject(message);

            //LoggerHelper.AndroidPush($"1.给[{touid}]推送的消息内容为:{Environment.NewLine}{messageJson}");

            try
            {
                String pushResult = push.pushMessageToSingle(message, target);
                //LoggerHelper.AndroidPush($"2.给[{touid}]推送的消息返回结果为{Environment.NewLine}{pushResult}");

                //_dataService.InsertGeguiLog(msg.fromuid, touid, msg.msgtime, msg.id0, "android", deviceid, messageJson);
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                LoggerHelper.AndroidPush($"3.给[{touid}]推送发生了异常,重发后,服务端返回结果{Environment.NewLine}{pushResult}");
            }
        }
Ejemplo n.º 16
0
        //PushMessageToList接口测试代码
        private static void PushMessageToList()
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            ListMessage message = new ListMessage();

            NotificationTemplate template = new NotificationTemplate();
            template.AppId = APPID;                             // 应用APPID
            template.AppKey = APPKEY;                           // 应用APPKEY
            template.Title = "此处填写通知标题";                // 通知标题
            template.Text = "此处填写通知内容";                 // 通知内容
            template.Logo = "icon.png";                         // 应用Logo
            template.LogoURL = "http://www.photophoto.cn/m23/086/010/0860100017.jpg"; //通知栏网络图片展示
            template.TransmissionType = "2";                    // 收到消息是否立即启动应用,1为立即启动,2则广播等待客户端自启动
            template.TransmissionContent = "你需要透传的内容";  // 需要透传的内容
            //template.IsRing = true;					// 收到通知是否响铃,可选,默认响铃
            //template.IsVibrate = true;					// 收到通知是否震动,可选,默认振动
            //template.IsClearable = true;				// 通知是否可清除,可选,默认可清除

            message.IsOffline = true;                         // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;            // 离线有效时间,单位为毫秒,可选
            message.Data = template;

            //设置接收者
            List<com.igetui.api.openservice.igetui.Target> targetList = new List<com.igetui.api.openservice.igetui.Target>();
            com.igetui.api.openservice.igetui.Target target1 = new com.igetui.api.openservice.igetui.Target();
            target1.appId = APPID;
            target1.clientId = CLIENTID;

            // 如需要,可以设置多个接收者
            //com.igetui.api.openservice.igetui.Target target2 = new com.igetui.api.openservice.igetui.Target();
            //target2.AppId = APPID;
            //target2.ClientId = "ddf730f6cabfa02ebabf06e0c7fc8da0";

            targetList.Add(target1);
            //targetList.Add(target2);

            String contentId = push.getContentId(message);
            String pushResult = push.pushMessageToList(contentId, targetList);
            System.Console.WriteLine("-----------PushMessageToList--------------" + pushResult);
        }
Ejemplo n.º 17
0
        //PushMessageToSingle接口测试代码
        private static void PushMessageToSingle()
        {
            // 推送主类
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            //通知模版:支持TransmissionTemplate、LinkTemplate、NotificationTemplate,此处以TransmissionTemplate为例
            TransmissionTemplate template = new TransmissionTemplate();
            template.AppId = APPID;                             // 应用APPID
            template.AppKey = APPKEY;                           // 应用APPKEY
            template.TransmissionType = "1";                    // 收到消息是否立即启动应用,1为立即启动,2则广播等待客户端自启动
            template.TransmissionContent = "您需要透传的内容";  // 需要透传的内容

            //iOS推送需要的pushInfo字段
            //template.setPushInfo(actionLocKey, badge, message, sound, payload, locKey, locArgs, launchImage);

            // 单推消息模型
            SingleMessage message = new SingleMessage();
            message.IsOffline = true;                         // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;            // 离线有效时间,单位为毫秒,可选
            message.Data = template;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId = APPID;
            target.clientId = CLIENTID;

            String pushResult = push.pushMessageToSingle(message, target);
            System.Console.WriteLine("-----------PushMessageToSingle--------------" + pushResult);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///  推送1-n个用户(用户别名)
        /// </summary>
        /// <param name="pushMessageInfo">推送信息实体</param>
        private void PushMessageToList(PushMessageInfo pushMessageInfo)
        {
            int     isMute              = 0;//设定是否静音,只在于推送 客户等于1时可用
            IGtPush push                = new IGtPush(HOST, APPKEY, MASTERSECRET);
            string  content             = pushMessageInfo.Contents;
            string  title               = string.Empty;
            var     transmissionContent =
                new
            {
                Template = pushMessageInfo.Template,
                Content  = pushMessageInfo.Contents,
                Url      = pushMessageInfo.Url,
                Section  = pushMessageInfo.TypeID + "/" + pushMessageInfo.Section,
                NodeId   = pushMessageInfo.DataID
            };
            string jsonContent = JsonHelper.ConvertToJson(transmissionContent);

            PushLog("- - - - - - - - - - - - - ");
            PushLog(string.Format("推送类型:{0}", pushMessageInfo.PushType));
            PushLog(string.Format("推送内容:{0}", pushMessageInfo.Contents));
            PushLog(string.Format("推送目标:{0}", pushMessageInfo.TargetList));
            if (pushMessageInfo.TypeID != 0)
            {
                title = Enum.GetName(typeof(SectionSecondType), pushMessageInfo.Section);
            }
            //设置接收者
            List <com.igetui.api.openservice.igetui.Target> targetList = new List <com.igetui.api.openservice.igetui.Target>();

            if (pushMessageInfo.TargetList.IndexOf(",") == -1)
            {
                pushMessageInfo.TargetList += ",";
            }
            string[] targets = pushMessageInfo.TargetList.Split(',');

            for (int i = 0; i < targets.Length; i++)
            {
                if (targets[i] != null && targets[i] != string.Empty && targets[i] != "")
                {
                    com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
                    target.appId = APPID;
                    target.alias = targets[i];

                    #region 判定是否允许推送,并向java接口写入推送信息
                    MessagesAddBLL     pushBLL   = new MessagesAddBLL();
                    MessagesAddRequest maRequest = new MessagesAddRequest();
                    maRequest.creator = "推送程序";
                    maRequest.userID  = Convert.ToInt32(target.alias);
                    maRequest.status  = 0;
                    if (pushMessageInfo.Template == 1)
                    {
                        maRequest.contents = pushMessageInfo.Contents;
                    }
                    else
                    {
                        maRequest.contents = pushMessageInfo.Url;
                    }
                    if (pushMessageInfo.TypeID != 0)
                    {
                        maRequest.typeID = pushMessageInfo.TypeID;
                    }
                    if (pushMessageInfo.Section != 0)
                    {
                        maRequest.dataTypeID = pushMessageInfo.Section;
                    }
                    maRequest.dataID = pushMessageInfo.DataID;

                    //写入至未读消息列表
                    var respon = pushBLL.MessagesAdd(maRequest);
                    //IOS 数据判定开关
                    if (pushMessageInfo.ChannelID == 1 || pushMessageInfo.ChannelID == 0)
                    {
                        NotifyConfigGetBLL     notifyConfigGetBLL = new NotifyConfigGetBLL();
                        NotifyConfigGetRequest request            = new NotifyConfigGetRequest();
                        request.userID       = maRequest.userID;
                        request.userPlatform = 3;
                        NotifyConfigGetResponse ncgResponse = notifyConfigGetBLL.NotityConfigGet(request);
                        //转化为2进制字符串后换算出是否推送
                        //string allStatus = Convert.ToString(1, 2);
                        string allStatus = Convert.ToString(ncgResponse.notifyConfig.notifySwitch, 2);
                        int    t         = GetIntegerSomeBit(ncgResponse.notifyConfig.notifySwitch, maRequest.typeID - 1);
                        if (targets.Length == 2)
                        {
                            //静音的二进制返回位数
                            isMute = GetIntegerSomeBit(ncgResponse.notifyConfig.notifySwitch, 4);
                        }
                        //包含用户已有权限+不存在的用户
                        if (t == 0)
                        {
                            if (respon.code == 0)
                            {
                                targetList.Add(target);
                            }
                            else
                            {
                                PushLog(string.Format("消息写入失败,无法推送:{0}", maRequest.userID));
                            }
                        }
                        else
                        {
                            PushLog(string.Format("跳过推送ID:{0}", maRequest.userID));
                        }
                    }
                    else //Android
                    {
                        if (respon.code == 0)
                        {
                            targetList.Add(target);
                        }
                        else
                        {
                            PushLog(string.Format("消息写入失败,无法推送:{0}", maRequest.userID));
                        }
                    }

                    #endregion
                }
            }


            if (targetList == null || targetList.Count == 0)
            {
                return;
            }
            #region 因为IOS端需要静音,透传模板放置在方法底部
            ListMessage message = new ListMessage();

            //设置透传模板
            TransmissionTemplate template = TransmissionTemplateDemo(content, title, jsonContent, isMute);
            template.TransmissionType    = "2";          //应用启动类型,1:强制应用启动 2:等待应用启动
            template.TransmissionContent = jsonContent;  //透传内容
            message.IsOffline            = true;
            message.OfflineExpireTime    = 1000 * 3600 * 12;
            message.Data = template;
            #endregion
            string contentId  = push.getContentId(message);
            string pushResult = push.pushMessageToList(contentId, targetList);
            try
            {
                var result = JsonHelper.ConvertToObj <PushResult>(pushResult);
                PushLog("推送结果:" + result.result);
            }
            catch
            {
                PushLog("推送结果转换异常");
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 6 - 12 研讨类消息
        /// </summary>
        /// <param name="deviceid"></param>
        /// <param name="msgtype"></param>
        /// <param name="msg"></param>
        /// <param name="touid"></param>
        /// <returns></returns>
        public static async Task PushDiscussMessage(string deviceid, int msgtype, string msg, string touid)
        {
            var    currentMethod = "PushDiscussMessage";
            object model         = null;
            var    content       = "新的研讨消息";

            if (msgtype == 6)
            {
                var m = JsonConvert.DeserializeObject <AddDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 7)
            {
                var m = JsonConvert.DeserializeObject <DeleteDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 8)
            {
                var m = JsonConvert.DeserializeObject <ModifyDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 9)
            {
                var m = JsonConvert.DeserializeObject <FinishDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 10)
            {
                var m = JsonConvert.DeserializeObject <ActivateDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 11)
            {
                var m = JsonConvert.DeserializeObject <RemindDiscuss>(msg);
                content = m.Name + "有新的研讨消息";
                model   = m;
            }
            else if (msgtype == 12)
            {
                var m = JsonConvert.DeserializeObject <Note>(msg);
                content = m.Title + "有新的研讨消息";
                model   = m;
            }



            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            //消息模版:TransmissionTemplate:透传模板
            var intent = $"intent:#Intent;component=net.cnki.okms/.pages.base.BootActivity;end";
            var title  = "协同研讨";

            var getui = new GeTuiMessage
            {
                mtype    = msgtype,
                mcontent = model,
            };

            TransmissionTemplate template = TransmissionTemplate(title, content, intent, JsonConvert.SerializeObject(getui));



            // 单推消息模型
            SingleMessage message = new SingleMessage();

            message.IsOffline         = true;                 // 用户当前不在线时,是否离线存储,可选
            message.OfflineExpireTime = 1000 * 3600 * 12;     // 离线有效时间,单位为毫秒,可选
            message.Data = template;
            //判断是否客户端是否wifi环境下推送,2为4G/3G/2G,1为在WIFI环境下,0为不限制环境
            //message.PushNetWorkType = 1;

            com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
            target.appId    = APPID;
            target.clientId = deviceid;
            //target.alias = ALIAS;

            var messageJson = JsonConvert.SerializeObject(message);

            LoggerHelper.AndroidPush($"1.个推-研讨类消息[{touid}]推送的消息内容为:{Environment.NewLine}{messageJson}");

            try
            {
                String pushResult = push.pushMessageToSingle(message, target);
                LoggerHelper.AndroidPush($"2.(个推-研讨类消息)给[{touid}]返回结果:" + pushResult);
            }
            catch (RequestException e)
            {
                String requestId = e.RequestId;
                //发送失败后的重发
                String pushResult = push.pushMessageToSingle(message, target, requestId);
                LoggerHelper.AndroidPush($"3.(个推-研讨类消息)给[{touid}]发生了异常,重发后,服务端返回结果:----------------" + pushResult);
            }
        }