Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. protected override void OnStart()
  2. {
  3. // This should come before AppCenter.Start() is called
  4. // Avoid duplicate event registration:
  5. if (!AppCenter.Configured)
  6. {
  7. Push.PushNotificationReceived += (sender, e) =>
  8. {
  9. var title = e.Title;
  10. var message = e.Message;
  11.  
  12. // If app is in background title and message are null
  13. // App in foreground
  14. if (!string.IsNullOrEmpty(title))
  15. {
  16. foreach (string key in e.CustomData.Keys)
  17. {
  18. if (e.CustomData[key] == Settings.WorkerID)
  19. {
  20. Current.MainPage.DisplayAlert(title, message, "OK");
  21. }
  22. }
  23. }
  24. };
  25. }
  26.  
  27. // Handle when your app starts
  28. AppCenter.Start("android=xxxxxxxxxxxxxxxxxx", typeof(Push));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement