private static void ValidateRequest(AN_NotificationRequest request) { //Skipping this in the editor if (Application.isEditor) { return; } var builder = request.Content; //Saving the request id var list = GetScheduledList(); if (!list.Ids.Contains(request.Identifier)) { list.Ids.Add(request.Identifier); SaveScheduledNotificationsList(list); } //Skipping for the Android versions that does not support notification channels if (AN_Build.VERSION.SDK_INT < AN_Build.VERSION_CODES.O) { return; } //Let' check if user has provided a custom channel if (string.IsNullOrEmpty(builder.ChanelId)) { builder.SetChanelId(AN_NotificationChannel.ANDROID_NATIVE_DEFAULT_CHANNEL_ID); } var chanelId = builder.ChanelId; var channel = GetNotificationChannel(chanelId); //We will create channel in 2 cases //1 if you specified channel that doesn't yet exists //2 fall back to default channel, that should always be updated according to a builder settings if (channel == null || chanelId.Equals(AN_NotificationChannel.ANDROID_NATIVE_DEFAULT_CHANNEL_ID)) { channel = new AN_NotificationChannel(chanelId, "Default", Importance.DEFAULT); channel.Sound = builder.SoundName; CreateNotificationChannel(channel); } }
/// <summary> /// Unschedule the specified notification request. /// </summary> /// <param name="request">request to Unschedule.</param> public static void Unschedule(AN_NotificationRequest request) { Unschedule(request.Identifier); }
/// <summary> /// Schedules a local notification for delivery. /// See <see cref="Cancel(int)"/> for the detailed behavior. /// </summary> /// <param name="request">The notification request to schedule.This parameter must not be <c>null</c>.</param> public static void Schedule(AN_NotificationRequest request) { ValidateRequest(request); AN_Java.Bridge.CallStatic(k_NotificationsManager, "Schedule", request); }