public void testGetAliasDeviceList_1()
        {
            JPushClient           pushClient = new JPushClient(APP_KEY, MASTER_SECRET);
            AliasDeviceListResult result     = pushClient.getAliasDeviceList("alias1", null);

            Assert.IsTrue(result.registration_ids.Contains(REGISTRATION_ID1));
        }
        public void testGetAliasDeviceList_2()
        {
            JPushClient           pushClient = new JPushClient(APP_KEY, MASTER_SECRET);
            AliasDeviceListResult result     = pushClient.getAliasDeviceList("alias2", null);

            Assert.IsTrue(result.registration_ids.Count == 0);
        }
        public void testGetAliasDeviceList()
        {
            JPushClient           pushClient = new JPushClient(APP_KEY, MASTER_SECRET);
            AliasDeviceListResult result     = pushClient.getAliasDeviceList("alias1", "android");

            Assert.IsTrue(result.isResultOK());
        }
示例#4
0
    public static AliasDeviceListResult fromResponse(ResponseWrapper responseWrapper)
    {
        AliasDeviceListResult aliasDeviceListResult = new AliasDeviceListResult();

        if (responseWrapper.isServerResponse())
        {
            aliasDeviceListResult = JsonConvert.DeserializeObject <AliasDeviceListResult>(responseWrapper.responseContent);
        }
        aliasDeviceListResult.ResponseResult = responseWrapper;
        return(aliasDeviceListResult);
    }
示例#5
0
    // ------------- alias

    public AliasDeviceListResult getAliasDeviceList(String alias, String platform)
    {
        String url = HOST_NAME_SSL + ALIASES_PATH + "/" + alias;

        if (null != platform)
        {
            url += "?platform=" + platform;
        }
        ResponseWrapper response = this.sendGet(url, Authorization(), null);

        return(AliasDeviceListResult.fromResponse(response));
    }
示例#6
0
        /// <summary>
        /// 指定aliasIds
        /// </summary>
        /// <param name="content"></param>
        /// <param name="aliasIds"></param>
        /// <returns></returns>
        public async Task <bool> PushToAlias(string title, string content, List <string> aliasIds)
        {
            List <string> aliasList = new List <string>();

            foreach (var item in aliasIds)
            {
                AliasDeviceListResult aliasDevice = client.getAliasDeviceList(item, "android");
                if (aliasDevice.registration_ids.Count > 0)
                {
                    aliasList.Add(item);
                }
            }
            if (aliasList.Count == 0)
            {
                return(await Task.FromResult(true));
            }

            PushPayload pushPayload = CreatePayload(title, content, null, aliasList.ToArray());

            MessageResult response = client.SendPush(pushPayload);

            return(await Task.FromResult(response.isResultOK()));
        }