protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback) { var content = new ISN_UNNotificationContent(); content.Title = request.Content.Title; content.Body = request.Content.Body; if (string.IsNullOrEmpty(request.Content.SoundName)) { content.Sound = ISN_UNNotificationSound.DefaultSound; } else { content.Sound = ISN_UNNotificationSound.SoundNamed(request.Content.SoundName); } ISN_UNNotificationTrigger trigger = null; if (request.Trigger is UM_TimeIntervalNotificationTrigger) { UM_TimeIntervalNotificationTrigger timeIntervalTrigger = (UM_TimeIntervalNotificationTrigger)request.Trigger; trigger = new ISN_UNTimeIntervalNotificationTrigger(timeIntervalTrigger.Interval, timeIntervalTrigger.Repeating); } var ios_request = new ISN_UNNotificationRequest(request.Identifier.ToString(), content, trigger); ISN_UNUserNotificationCenter.AddNotificationRequest(ios_request, callback); }
protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback) { try { var builder = new AN_NotificationCompat.Builder(); builder.SetContentTitle(request.Content.Title); builder.SetContentText(request.Content.Body); if (request.Content.BadgeNumber != -1) { builder.SetNumber(request.Content.BadgeNumber); } if (string.IsNullOrEmpty(request.Content.SoundName)) { builder.SetDefaults(AN_Notification.DEFAULT_LIGHTS | AN_Notification.DEFAULT_SOUND); } else { string soundName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.SoundName); builder.SetSound(soundName); } if (!string.IsNullOrEmpty(request.Content.IconName)) { string iconName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.IconName); builder.SetSmallIcon(iconName); } if (request.Content.LargeIcon != null) { builder.SetLargeIcon(request.Content.LargeIcon); } UM_TimeIntervalNotificationTrigger timeIntervalTrigger = (UM_TimeIntervalNotificationTrigger)request.Trigger; var trigger = new AN_AlarmNotificationTrigger(); trigger.SetDate(TimeSpan.FromSeconds(timeIntervalTrigger.Interval)); trigger.SerRepeating(timeIntervalTrigger.Repeating); var android_request = new AN_NotificationRequest(request.Identifier, builder, trigger); AN_NotificationManager.Schedule(android_request); callback.Invoke(new SA_Result()); } catch (Exception ex) { var error = new SA_Error(100, ex.Message); callback.Invoke(new SA_Result(error)); } }
private UM_NotificationRequest ToUMRequest(AN_NotificationRequest android_request) { var content = new UM_Notification(); content.SetTitle(android_request.Content.Title); content.SetBody(android_request.Content.Text); var interval = (long)android_request.Trigger.Seconds; var repeating = android_request.Trigger.Repeating; var timeIntervalTrigger = new UM_TimeIntervalNotificationTrigger(interval); timeIntervalTrigger.SerRepeating(repeating); var request = new UM_NotificationRequest(android_request.Identifier, content, timeIntervalTrigger); return(request); }
private UM_NotificationRequest ToUMRequest(ISN_UNNotificationRequest ios_request) { var content = new UM_Notification(); content.SetTitle(ios_request.Content.Title); content.SetBody(ios_request.Content.Body); var timeIntervalTrigger = (ISN_UNTimeIntervalNotificationTrigger)ios_request.Trigger; var interval = timeIntervalTrigger.TimeInterval; var repeating = timeIntervalTrigger.Repeats; var trigger = new UM_TimeIntervalNotificationTrigger(interval); trigger.SerRepeating(repeating); var Identifier = Convert.ToInt32(ios_request.Identifier); var request = new UM_NotificationRequest(Identifier, content, trigger); return(request); }