Exemple #1
0
        public static string GeTuiMsg(string msgTitle, string msgBody, string appid, string appkey, string mastersecret, string clientId, DateTime?msgPostTime)
        {
            var HOST = "http://sdk.open.api.igexin.com/apiex.htm";

            var push = new IGtPush(HOST, appkey, mastersecret);
            // 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
            var batch = new BatchImpl(appkey, push);
            //var message = new AppMessage();
            var message = new SingleMessage();
            //var template = NotificationTemplateDemo(msgTitle, msgBody, appid, appkey, msgPostTime);
            var template = TransmissionContent(msgTitle, msgBody, appid, appkey);

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

            var targetTrans = new Target
            {
                appId    = appid,
                clientId = clientId
            };

            batch.add(message, targetTrans);
            try
            {
                return(batch.submit());
            }
            catch
            {
                return(batch.retry());
            }
        }
Exemple #2
0
        public override string Push()
        {
            var message = new SingleMessage
            {
                Data              = GeTui.ToTemplate(PhoneType, TemplateType),
                IsOffline         = true,             // 用户当前不在线时,是否离线存储,可选
                OfflineExpireTime = 1000 * 3600 * 12, // 离线有效时间,单位为毫秒,可选
                PushNetWorkType   = 0                 //判断是否客户端是否wifi环境下推送,1为在WIFI环境下,0为不限制网络环境。
            };
            var batch = new BatchImpl(ConfigSettings.AppKey, this);

            foreach (var cid in GeTui.ClientId.Split(','))
            {
                var target = new Target
                {
                    appId    = ConfigSettings.AppId,
                    clientId = cid
                };
                batch.add(message, target);
            }
            try
            {
                return(batch.submit());
            }
            catch (Exception)
            {
                return(batch.retry());
            }
        }