PushNotificator.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PushNotificator : MonoBehaviour {
  5. // use for initialization
  6. void Start()
  7. {
  8. Pushwoosh.ApplicationCode = "5C944-4CEA2";
  9. Pushwoosh.GcmProjectNumber = "859354393071";
  10. Pushwoosh.Instance.OnRegisteredForPushNotifications += OnRegisteredForPushNotifications;
  11. Pushwoosh.Instance.OnFailedToRegisteredForPushNotifications += OnFailedToRegisteredForPushNotifications;
  12. Pushwoosh.Instance.OnPushNotificationsReceived += OnPushNotificationsReceived;
  13. Pushwoosh.Instance.RegisterForPushNotifications();
  14. }
  15. void OnRegisteredForPushNotifications(string token)
  16. {
  17. // handle here
  18. Debug.Log("Received token: \n" + token);
  19. }
  20. void OnFailedToRegisteredForPushNotifications(string error)
  21. {
  22. // handle here
  23. Debug.Log("Error ocurred while registering to push notifications: \n" + error);
  24. }
  25. void OnPushNotificationsReceived(string payload)
  26. {
  27. // handle here
  28. Debug.Log("Received push notificaiton: \n" + payload);
  29. }
  30. }