/// <summary> /// 带两个参数的构造函数,该状态下,ApnsProduction默认为false /// </summary> /// <param name="app_key">Portal上产生的app_key</param> /// <param name="masterSecret">你的API MasterSecret</param> public JPushClient(String app_key, String masterSecret) { _pushClient = new PushClient(app_key, masterSecret); _reportClient = new ReportClient(app_key, masterSecret); _deviceClient = new DeviceClient(app_key, masterSecret); }
public static void Main(string[] args) { Console.WriteLine("*****开始获取设备信息******"); DeviceClient client = new DeviceClient(app_key, master_secret); //get device tag alias try { var result = client.getDeviceTagAlias(REGISTRATION_ID); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } // update Device ALIAS,MOBILE,TAG try { var result = client.updateDevice(REGISTRATION_ID, ALIAS, MOBILE, TAG_HASHSET, TAG_HASHSET_REMOVE ); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } //get tag list demo try { var result = client.getTagList(); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } //get device tag alias try { var result = client.getDeviceTagAlias(REGISTRATION_ID); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } try { var result = client.updateDeviceTagAlias(REGISTRATION_ID, true, true); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } //get the device tag alias mobile try { var result = client.getDeviceTagAlias(REGISTRATION_ID); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } //TagAliasResult getDeviceTagAlias(String registrationId) Console.WriteLine("*****结束获取设备信息******"); //get the device tag alias mobile try { var result = client.getDeviceStatus(REGISTRATION_IDS); //由于统计数据并非非是即时的,所以等待一小段时间再执行下面的获取结果方法 System.Threading.Thread.Sleep(10000); //如需查询上次推送结果执行下面的代码 Console.WriteLine(result); //如需查询某个messageid的推送结果执行下面的代码 } catch (APIRequestException e) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + e.Status); Console.WriteLine("Error Code: " + e.ErrorCode); Console.WriteLine("Error Message: " + e.ErrorMessage); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } //TagAliasResult getDeviceTagAlias(String registrationId) Console.WriteLine("*****结束获取设备信息******"); }
public void updateDeviceInvalidMobileTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); client.updateDevice(REGISTRATION_ID1, "alias", "13", TAG_HASHSET_EMPTY, TAG_HASHSET_EMPTY); }
public void updateDeviceNullTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); client.updateDevice(REGISTRATION_ID1,null,null, TAG_HASHSET_EMPTY, TAG_HASHSET_EMPTY); }
public void updateDeviceEmptyTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); client.updateDevice(REGISTRATION_ID1, "", "13888888888", TAG_HASHSET_EMPTY, TAG_HASHSET_EMPTY); }
public void getDeviceTagAliasTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); client.getDeviceTagAlias(REGISTRATION_ID1); }
public void getDeviceTagAliasEmptyTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); client.getDeviceTagAlias(""); }
public void DeviceClientValidTest() { DeviceClient client = new DeviceClient(APP_KEY, MASTER_SECRET); Assert.IsInstanceOfType(client,typeof(DeviceClient)); }
public void DeviceClientEmptyTest() { DeviceClient client = new DeviceClient("", ""); }