Ejemplo n.º 1
0
 public string pushAPNMessageToList(
     string appId,
     string contentId,
     List <string> deviceTokenlist)
 {
     foreach (var str in deviceTokenlist)
     {
         if (str == null || str.Length != 64)
         {
             throw new Exception("deviceToken length must be 64");
         }
     }
     return(httpPostJSON(new Dictionary <string, object>
     {
         {
             "action",
             "apnPushToListAction"
         },
         {
             "appkey",
             appKey
         },
         {
             nameof(appId),
             appId
         },
         {
             nameof(contentId),
             contentId
         },
         {
             "DTL",
             deviceTokenlist
         },
         {
             "needDetails",
             GtConfig.isPushListNeedDetails()
         },
         {
             "async",
             GtConfig.isPushListAsync()
         }
     }));
 }
Ejemplo n.º 2
0
        public string pushMessageToList(string contentId, List <Target> targetList)
        {
            var flag1    = GtConfig.isPushListAsync();
            var flag2    = GtConfig.isPushListNeedAliasDetails();
            var flag3    = GtConfig.isPushListNeedDetails();
            var postData = new Dictionary <string, object>
            {
                {
                    "action",
                    "pushMessageToListAction"
                },
                {
                    "appkey",
                    appKey
                },
                {
                    nameof(contentId),
                    contentId
                },
                {
                    "needDetails",
                    flag3
                },
                {
                    "needAliasDetails",
                    flag2
                },
                {
                    "async",
                    flag1
                }
            };
            var num = !flag1 || flag3?GtConfig.getSyncListLimit() : GtConfig.getAsyncListLimit();

            if (targetList.Count > num)
            {
                return("target size:" + targetList.Count + " beyond the limit:" + num);
            }
            var stringList1 = new List <string>();
            var stringList2 = new List <string>();
            var str         = "";

            foreach (var target in targetList)
            {
                var clientId = target.clientId;
                var alias    = target.alias;
                if (!string.IsNullOrWhiteSpace(clientId))
                {
                    stringList1.Add(clientId);
                }
                else if (!string.IsNullOrWhiteSpace(alias))
                {
                    stringList2.Add(alias);
                }
                if (string.IsNullOrWhiteSpace(str))
                {
                    str = target.appId;
                }
            }

            postData.Add("appId", str);
            postData.Add("clientIdList", stringList1);
            postData.Add("aliasList", stringList2);
            postData.Add("type", 2);
            return(httpPostJSON(host, postData, true));
        }