Closed lafarcito closed 5 years ago
Hi @lafarcito ,
Best regards, Yuriy, Universal Tools team.
My Script with custom class for schedule notification
public enum NOTIFICATION_ID { DailyNotification = 0, WeekNotification = 1, Week2Notification = 2, Week3Notification = 3, MonthNotification = 4}
[System.Serializable] public class CustomNotification { [SerializeField] NOTIFICATION_ID id; public NOTIFICATION_ID Id { get { return id; } } [SerializeField] int triggerTime; public int TriggerTime { get { return triggerTime; } } [SerializeField] string title; public string Title { get { return title; } } string message; public string Message { get { return message; } } }
public class NotificationManager : MonoBehaviour { private static NotificationManager instance; [SerializeField] CustomNotification[] notification;
private void Awake() { if (instance == null) { instance = this; }else if (instance != this) { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); } // Start is called before the first frame update void Start() { UTNotifications.Manager.Instance.Initialize(false); UTNotifications.Manager.Instance.SetNotificationsEnabled(true); // I have try enabling this but nothing happen UTNotifications.Manager.Instance.PostLocalNotification("Title", "Hello", 100); for (int i = 0; i < notification.Length; i++) { UTNotifications.Manager.Instance.ScheduleNotification(notification[i].TriggerTime, notification[i].Title, notification[i].Message,(int) notification[i].Id); } }
}
Target device MIA1 Oreo
Thanks, most likely either notification[i].Title
or notification[i].Message
(or both) is null.
I suspect Message
, as string message;
is missing [SerializeField]
Nice! Thank you!
I get this error when i try to play notification scheduled.
03-18 10:38:16.515 31799-31799/com.AAA.BBB E/universal.tools.notifications.Manager: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
Local notification work fine but cant schedule