示例#1
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();
            }
        }
示例#2
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);
        }