public getSchedule ( int pageid ) : |
||
pageid | int | |
Résultat |
public static void Main(string[] args) { //init a pushpayload PushPayload pushPayload = new PushPayload(); pushPayload.platform = Platform.all(); pushPayload.audience = Audience.all(); pushPayload.notification = new Notification().setAlert(ALERT); ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret); //get schedule try { var result = scheduleclient.getSchedule(PAGEID); Console.WriteLine(result.schedules[0].name); Console.WriteLine(result.schedules); Console.WriteLine(result); } 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.ErrorCode); } catch (APIConnectionException e) { Console.WriteLine(e.Message); } }
public static void Main(string[] args) { //init a pushpayload PushPayload pushPayload = new PushPayload(); pushPayload.platform = Platform.all(); pushPayload.audience = Audience.all(); pushPayload.notification = new Notification().setAlert(ALERT); ScheduleClient scheduleclient = new ScheduleClient(app_key, master_secret); //init a TriggerPayload TriggerPayload triggerConstructor = new TriggerPayload(START, END, TIME_PERIODICAL, TIME_UNIT, FREQUENCY, POINT); //init a SchedulePayload SchedulePayload schedulepayloadperiodical = new SchedulePayload(NAME, ENABLED,triggerConstructor,pushPayload); try { var result = scheduleclient.sendSchedule(schedulepayloadperiodical); Console.WriteLine(result); } 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); } SchedulePayload schedulepayloadsingle = new SchedulePayload(); TriggerPayload triggersingle = new TriggerPayload(TIME); schedulepayloadsingle.setPushPayload(pushPayload); schedulepayloadsingle.setTrigger(triggersingle); schedulepayloadsingle.setName(NAME); schedulepayloadsingle.setEnabled(ENABLED); try { var result = scheduleclient.sendSchedule(schedulepayloadsingle); Console.WriteLine(result); } 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 schedule try { var result = scheduleclient.getSchedule(PAGEID); Console.WriteLine(result.schedules[0].name); Console.WriteLine(result.schedules); Console.WriteLine(result); } 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 schedule by id try { var result = scheduleclient.getScheduleById(PUT_SCHEDULE_ID); Console.WriteLine(result.name); Console.WriteLine(result); } 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); } //PUT the name SchedulePayload putschedulepayload = new SchedulePayload(); putschedulepayload.setName(NAME); //the default enabled is true,if you want to change it,you have to set it to false try { var result = scheduleclient.putSchedule(putschedulepayload, SCHEDULE_ID); Console.WriteLine(result); } 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); } //delete Schedule try { // add the right var result = scheduleclient.deleteSchedule(SCHEDULE_ID); Console.WriteLine(result); } 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); } }