Advertisement
minafaw3

subscribePushNotifications

Apr 27th, 2020
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. private void subscribePushNotifications(String inbox ){
  2. Calendar cal = Calendar.getInstance();
  3. cal.add(Calendar.HOUR_OF_DAY , 1);
  4. Subscription sub = new Subscription();
  5. sub.notificationUrl = "https://ad3309c4.ngrok.io/cats/tickets/notifications";
  6. sub.changeType = "updated";
  7. sub.resource = "users/"+inbox+"/messages";
  8. sub.expirationDateTime = cal;
  9. sub.clientState = "SecretClientState";
  10.  
  11. MSGraphAuthenticationProvider provider = new MSGraphAuthenticationProvider();
  12. IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(provider).buildClient();
  13. graphClient.subscriptions().buildRequest().post(sub, new ICallback<Subscription>() {
  14. @Override
  15. public void success(Subscription subscription) {
  16. System.out.println("Subscription " + subscription);
  17. }
  18.  
  19. @Override
  20. public void failure(ClientException e) {
  21. System.out.println("ClientException " + e);
  22. }
  23. });
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement