How to handle iOS local notification Click?

Hi,

I am using iOS LocalNotification class to schedule notifications. When a user clicks on the notification, I want my application behavior to change based on the information stored in the notification.

But I am not able to figure out out how to do that. Is there some function that gets called when an application opens via a notification.

Thanks.

1 Answer

1

Hi. Try use UnityEngine.iOS.NotificationServices.localNotifications and custom data with ID of your local notifications.

void Check (string id)
	{
		Dictionary<string,string> customData = new Dictionary<string, string> ();
		customData.Add ("id", id);    
		foreach (UnityEngine.iOS.LocalNotification note in     
                              UnityEngine.iOS.NotificationServices.localNotifications) {	
			IDictionary dic = note.userInfo;
			foreach (string value in dic.Values)
			{ 
				if (value == customData["id"])
				{
					Do something
				}
			}
		}
	}

void OnApplicationFocus(bool focusStatus) {
	if (focusStatus) {
			Check("my_id");
	}
	else {
	}
}

Please avoid posting comments as answers. This has been converted on your behalf.