예제 #1
0
        private string PushMessageToAppAndroid(RequestPushMessageToApp req)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            AppMessage message = new AppMessage();

            NotificationTemplate template = NotificationTemplateAndroid(req.Title);

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

            List<String> appIdList = new List<string>();
            appIdList.Add(APPID);

            List<String> phoneTypeList = new List<string>();    //通知接收者的手机操作系统类型
            phoneTypeList.Add("ANDROID");
            //phoneTypeList.Add("IOS");

            List<String> provinceList = new List<string>();     //通知接收者所在省份

            message.AppIdList = appIdList;
            message.PhoneTypeList = phoneTypeList;
            message.ProvinceList = provinceList;

            String pushResult = push.pushMessageToApp(message);
            return pushResult;
        }
예제 #2
0
        private void pushMessageToAppIOS(string title)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            AppMessage message = new AppMessage();

            //通知模版:支持TransmissionTemplate、LinkTemplate、NotificationTemplate,此处以LinkTemplate为例
            TransmissionTemplate template = TransmissionTemplateIOS(title);

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

            List<String> appIdList = new List<string>();
            appIdList.Add(APPID);

            List<String> phoneTypeList = new List<string>();    //通知接收者的手机操作系统类型
            phoneTypeList.Add("ANDROID");
            phoneTypeList.Add("IOS");

            List<String> provinceList = new List<string>();     //通知接收者所在省份
            //provinceList.Add("浙江");
            //provinceList.Add("上海");
            //provinceList.Add("北京");

            message.AppIdList = appIdList;
            message.PhoneTypeList = phoneTypeList;
            message.ProvinceList = provinceList;

            String pushResult = push.pushMessageToApp(message);
        }
예제 #3
0
        //pushMessageToApp接口测试代码
        private static void pushMessageToApp()
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);

            AppMessage message = new AppMessage();

            //通知模版:支持TransmissionTemplate、LinkTemplate、NotificationTemplate,此处以LinkTemplate为例
            LinkTemplate template = new LinkTemplate();
            template.AppId = APPID;                     //应用APPID
            template.AppKey = APPKEY;                   // 应用APPKEY
            template.Title = "toAPP消息";        // 通知标题
            template.Text = "toAPP消息";         // 通知内容
            template.Logo = "icon.png";                 // 通知Logo
            template.LogoURL = "http://www.photophoto.cn/m23/086/010/0860100017.jpg"; //通知栏网络图片展示
            template.Url = "http://www.baidu.com";            // 跳转地址
            //template.IsRing = true;					// 收到通知是否响铃,可选,默认响铃
            //template.IsVibrate = true;					// 收到通知是否震动,可选,默认振动
            //template.IsClearable = true;				// 通知是否可清除,可选,默认可清除

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

            List<String> appIdList = new List<string>();
            appIdList.Add(APPID);

            List<String> phoneTypeList = new List<string>();    //通知接收者的手机操作系统类型
            phoneTypeList.Add("ANDROID");
            //phoneTypeList.Add("IOS");

            List<String> provinceList = new List<string>();     //通知接收者所在省份
            //provinceList.Add("浙江");
            //provinceList.Add("上海");
            //provinceList.Add("北京");

            message.AppIdList = appIdList;
            message.PhoneTypeList = phoneTypeList;
            message.ProvinceList = provinceList;

            String pushResult = push.pushMessageToApp(message);
            System.Console.WriteLine("-----------pushMessageToApp--------------" + pushResult);
        }
예제 #4
0
        //pushMessageToApp接口测试代码
        public String pushMessageToApp(AppMessage message)
        {
            Dictionary<string, object> param = new Dictionary<string, object>();
            param.Add("action", "pushMessageToAppAction");
            param.Add("appkey", appKey);
            param.Add("transmissionContent", message.Data.getTransmissionContent());
            param.Add("isOffline", message.IsOffline);
            param.Add("offlineExpireTime", message.OfflineExpireTime);
            param.Add("appIdList", message.AppIdList);
            param.Add("phoneTypeList", message.PhoneTypeList);
            param.Add("provinceList", message.ProvinceList);
            param.Add("type", 2);
            param.Add("pushType", message.Data.getPushType());

            //Transparent.Builder builder = getTransparentBuilder();
            param.Add("clientData", Convert.ToBase64String(message.Data.getTransparent().ToByteArray()));

            // post数据
            String Result = httpPostJSON(param);
            System.Console.WriteLine("--------pushMessageToSingle result------------" + Result);
            return Result;
        }