- Home /
 
Error when checking if a notification has been delivered
Hello guys,
I am bit confused about how to check if a notification has been delivered. In my app I set a notification to be delivered for tomorrow. The notification gets delivered successfully when tomorrow comes but then I want to check if it got delivered so I schedule a new one for tomorrow again. But I get the following error inside onApplicationPause() method
10-09 21:41:19.816: E/Unity(13684): "NullReferenceException: Object reference not set to an instance of an object 10-09 21:41:19.816: E/Unity(13684): at Unity.Notifications.Android.AndroidNotificationCenter.CheckScheduledNotificationStatus (System.Int32 id) [0x00000] in :0 10-09 21:41:19.816: E/Unity(13684): at GameScript.OnApplicationPause (System.Boolean pause) [0x0000a] in :0 ".
This is the method:
        private void OnApplicationPause(bool pause)
      { 
     if(AndroidNotificationCenter.CheckScheduledNotificationStatus(morning_identifier) == 
    NotificationStatus.Delivered)
     {
         var today = DateTime.Now;
         //tommorows datetime strings
         var tomorrow_morning = new DateTime(today.Year, today.Month, today.Day, 11, 0, 0, DateTimeKind.Local).AddDays(1);
         
         PlayerPrefs.SetString("tomorrow_morning", tomorrow_morning.ToString());
         Guid guid = Guid.NewGuid();
         string str = guid.ToString();
         string channel_id = str + " channel";
        
         Debug.Log("Remove the notification from the status bar");
         AndroidNotificationCenter.CancelNotification(evening_identifier);
         setMorning_Channel(channel_id);
         setMorning_Notification(tomorrow_morning, channel_id);
     }
 
               I think the problem is because it doesn't know the morning_identifier, that I had declared when i set the notification. But how am I supposed to preserve the value? Thanks in advance.
Your answer
 
             Follow this Question
Related Questions
Mobile Notifications Icons on Android. 1 Answer
How to send local notification same hour everyday on Android ans iOS? 1 Answer
Is it possible to schedule repeatable notifications using Unity's Notifications Sample package? 0 Answers
Android/iOS notifications when the game is not running 1 Answer
Parse push notification doesn't show 0 Answers