private void DidLaunchWithLocalNotificationEvent(CrossPlatformNotification notification) { Debug.Log( $"Application did launch with local notification with id: {notification.GetNotificationID()}, fire date: {notification.FireDate}, interval: {notification.RepeatInterval}"); // try to find ReminderData associated with current notification and check, should we update data or not (for example for 1 time notifications what must be removed from the NotificationData) }
protected void OnNotificationReceived(CrossPlatformNotification _notification) { // Update properties alertBody.Value = _notification.AlertBody; fireDate.Value = _notification.FireDate.ToString(dateTimeFormat.Value); soundName.Value = _notification.SoundName; notificationID.Value = _notification.GetNotificationID(); // Update iOS properties CrossPlatformNotification.iOSSpecificProperties _iOSProperties = _notification.iOSProperties; if (_iOSProperties != null) { alertAction.Value = _iOSProperties.AlertAction; hasAction.Value = _iOSProperties.HasAction; badgeCount.Value = _iOSProperties.BadgeCount; launchImage.Value = _iOSProperties.LaunchImage; } CrossPlatformNotification.AndroidSpecificProperties _androidProperties = _notification.AndroidProperties; if (_androidProperties != null) { contentTitle.Value = _androidProperties.ContentTitle; tickerText.Value = _androidProperties.TickerText; tag.Value = _androidProperties.Tag; largeIcon.Value = _androidProperties.LargeIcon; } Fsm.Event(receivedEvent); }
private void DidReceiveLocalNotificationEvent(CrossPlatformNotification notification) { Debug.Log( $"Application received local notification with id: {notification.GetNotificationID()}, fire date: {notification.FireDate}, interval: {notification.RepeatInterval}"); // try to find ReminderData associated with current notification and check, should we update data or not (for example for 1 time notifications what must be removed from the NotificationData) // Also we must keep tracking of past reminders events to show it in a past dates ReminderData data = GetReminderByNotificationId(notification.GetNotificationID()); if (data != null) { Debug.Log($"This notification is a part of reminder by id: {data.id} and title: {data.title}"); data.AddToHistory(notification.FireDate); } else { Debug.LogWarning("There is no reminder data found for current notification!"); return; } SaveProgress(false); // show popup notifications UIManager.NotificationManager.ShowNotification( "TwoOptionsIconUINotification", -1, false, "", "Take asthma control test", _clockIcon, new string[] { "No", "Yes" }, new string[] { "Not completed", "Completed" }, new UnityAction[] { null, () => data.SetDone(true) }, () => SaveProgress(false) ); }
private void DidReceiveLocalNotificationEvent(CrossPlatformNotification _notification) { string id = _notification.GetNotificationID(); System.Action _callback; if (Receivecallbacks.TryGetValue(id, out _callback)) { _callback(); if (_notification.RepeatInterval == eNotificationRepeatInterval.NONE) { Receivecallbacks.Remove(id); } } Debug.Log("!!!!!!!!!!!!!!!!!DidReceiveLocalNotificationEvent"); }
void AppendNotificationResult(CrossPlatformNotification _notification) { string _alert = _notification.AlertBody; #pragma warning disable // Exists only for local notifications which will be useful if we need to cancel a local notification string _notificationIdentifier = _notification.GetNotificationID(); #pragma warning restore //Get UserInfo details IDictionary _userInfo = _notification.UserInfo; //Can get specific details of a notification based on platform /* * //For Android * _notification.AndroidProperties.ContentTitle * _notification.AndroidProperties.TickerText * * //For iOS * _notification.iOSProperties.AlertAction; * _notification.iOSProperties.BadgeCount; */ // Append to result list AppendResult("Alert = " + _alert); // Append user info string _userInfoDetails = null; if (_userInfo != null) { // Initialize and iterate through the list _userInfoDetails = string.Empty; foreach (string _key in _userInfo.Keys) { _userInfoDetails += _key + " : " + _userInfo[_key] + "\n"; } } else { _userInfoDetails = "NULL"; } AppendResult("UserInfo = " + _userInfoDetails); }
public void CancelLocalNotification(string _notificationID) { IList _scheduledNotifications = m_notificationCenter.ScheduledLocalNotifications; int _scheduledNotificationCount = _scheduledNotifications.Count; for (int _iter = 0; _iter < _scheduledNotificationCount; _iter++) { CrossPlatformNotification _scheduledNotification = _scheduledNotifications[_iter] as CrossPlatformNotification; string _scheduledNotificationID = _scheduledNotification.GetNotificationID(); // Cancel the notification which matches the given id if (!string.IsNullOrEmpty(_scheduledNotificationID) && _scheduledNotificationID.Equals(_notificationID)) { m_notificationCenter.CancelLocalNotification(_scheduledNotification); break; } } }