public void CreateNotificationChannel() { if (NotificationChannelsApiCheck()) { return; } var group = new NotificationChannelGroup(_groupIdInputField.text, RandomName()) { Description = "Android-Goodies test notification channel group" }; AGNotificationManager.CreateNotificationChannelGroup(group); var channel = NewNotificationChannel(_channelIdInputField.text, RandomName(), group.Id); channel.ShowBadge = true; AGNotificationManager.CreateNotificationChannel(channel); var retrievedChannel = AGNotificationManager.GetNotificationChannel(channel.Id); var retrievedGroup = AGNotificationManager.GetNotificationChannelGroup(group.Id); var msg = "Channel created: " + retrievedChannel + ", with group: " + retrievedGroup; Debug.Log(msg); _resultText.text = msg; _lastChannelId = channel.Id; }
public void DeleteNotificationChannelGroup() { if (NotificationChannelsApiCheck()) { return; } AGNotificationManager.DeleteNotificationChannelGroup(_groupIdInputField.text); }
public void OpenChannelSettings() { if (NotificationChannelsApiCheck()) { return; } AGNotificationManager.OpenNotificationChannelSettings(_channelIdInputField.text); }
public void CreateProgressBarNotification() { _notificationId++; var builder = CreateBaseNotificationBuilder() .SetContentTitle("Progress Bar Notification, id:" + _notificationId) .SetContentText("So progressive :)"); AGNotificationManager.Notify(_notificationId, builder.Build()); StartCoroutine(UpdateProgressBar(builder)); }
public void TrySetNotificationPolicy() { if (AGPermissions.IsPermissionGranted(AGPermissions.ACCESS_NOTIFICATION_POLICY)) { var policy = new AGNotificationManager.Policy(AGNotificationManager.Policy.PriorityCategory.Alarms, AGNotificationManager.Policy.PrioritySenders.Any, AGNotificationManager.Policy.PrioritySenders.Any); AGNotificationManager.SetNotificationPolicy(policy); } else { Debug.LogWarning("You do not have the rights to access Notification Policy"); _resultText.text = "You do not have the rights to access Notification Policy"; } }
public void LogNotificationParams() { if (AGNotificationManager.IsAppOpenedViaNotification) { var text = string.Format("App was opened via notification with parameters: {0}, {1}", AGNotificationManager.GetNotificationParameter(ParamKeyId), AGNotificationManager.GetNotificationParameter(ParamKeyDate)); _resultText.text = text; Debug.Log(text); } else { _resultText.text = "App was not open via notification"; } }
public void CreateScheduledNotification() { _notificationId++; var notification = CreateBaseNotificationBuilder() .SetContentTitle("Scheduled one!") .SetContentText("Id: " + _notificationId) .Build(); var time = DateTime.Now; time = time.AddSeconds(5); Debug.Log("Scheduled time is " + time + " with id: " + _notificationId); AGNotificationManager.Notify(_notificationId, notification, time); }
IEnumerator UpdateProgressBar(Notification.Builder builder) { var currentProgress = 0f; const float durationTime = 5f; const int maxProgress = 100; while (currentProgress < durationTime) { var progress = Mathf.CeilToInt(currentProgress / 5f * maxProgress); currentProgress += Time.deltaTime; builder.SetProgress(maxProgress, progress, false); AGNotificationManager.Notify(_notificationId, builder.Build()); yield return(null); } AGNotificationManager.Notify(_notificationId, builder.Build()); }
public void CreateRepeatingNotification() { _notificationId++; var notification = CreateBaseNotificationBuilder() .SetContentTitle("Repeating one!") .SetContentText("I will repeat!") .Build(); var time = DateTime.Now.AddSeconds(5); Debug.Log("NotificationsTest: scheduled time is " + time); // NOTE: as of API 19, all repeating alarms are inexact. If your // application needs precise delivery times then it must use one-time // exact alarms, rescheduling each time. const long intervalMillis = 10 * 1000L; // every 10 seconds AGNotificationManager.NotifyRepeating(null, _notificationId, notification, intervalMillis, time); }
public void CreateNotificationChannelGroup() { if (NotificationChannelsApiCheck()) { return; } var group = new NotificationChannelGroup(_groupIdInputField.text, RandomName()) { Description = "Android-Goodies test notification channel group" }; AGNotificationManager.CreateNotificationChannelGroup(group); var channelGroup = AGNotificationManager.GetNotificationChannelGroup(group.Id); Debug.Log("Channel group: " + channelGroup); _lastGroupId = group.Id; }
void Notify(Notification.Builder builder) { _notificationId++; AGNotificationManager.Notify(_notificationId, builder.Build()); }
public void CreateDifferentNotifications() { //Basic notification var builder = CreateBaseNotificationBuilder().SetContentTitle("Very basic one"); Notify(builder); //Notification with large icon var iconTexture = _goodiesSprite.texture; builder = CreateBaseNotificationBuilder() .SetContentTitle("With large icon!") .SetBadgeIconType(Notification.BadgeIcon.Large) .SetLargeIcon(iconTexture) .SetCategory(Notification.CategoryMessage); Notify(builder); //Notification with number (shown as badge on app icon) builder = CreateBaseNotificationBuilder() .SetContentTitle("With number") .SetNumber(20); Notify(builder); //Chronometer notification builder = CreateBaseNotificationBuilder() .SetContentTitle("UsesChronometer") .SetUsesChronometer(true); Notify(builder); //Notification with ticker and subtext builder = CreateBaseNotificationBuilder() .SetContentTitle("With subtext and ticker") .SetSubText("Some subtext").SetTicker("Accessibility text"); Notify(builder); //Auto-canceling notification (20s) builder = CreateBaseNotificationBuilder() .SetContentTitle("With timeout") .SetTimeoutAfter(20L * 1000L); Notify(builder); //Ongoing notification builder = CreateBaseNotificationBuilder() .SetContentTitle("Ongoing one") .SetOngoing(true); Notify(builder); //One-time alerting scheduled repeating notification builder = CreateBaseNotificationBuilder() .SetContentTitle("Alert once") .SetOnlyAlertOnce(true); var time = DateTime.Now.AddSeconds(5); const long intervalMillis = 2000; _notificationId++; AGNotificationManager.NotifyRepeating(null, _notificationId, builder.Build(), intervalMillis, time); //Notification with button - available in KitKat (20) or higher if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.KITKAT_WATCH) { builder = CreateBaseNotificationBuilder() .SetContentTitle("With button") .AddAction(Notification.CreateOpenUrlAction("https://github.com/TarasOsiris/android-goodies-docs-PRO/wiki", "notify_icon_small", "Open URL")); Notify(builder); } builder = CreateBaseNotificationBuilder().SetGroupSummary(true); Notify(builder); }
public void CancelAllNotifications() { AGNotificationManager.CancelAll(); }
public void CancelLastNotification() { AGNotificationManager.Cancel(_notificationId); }
public void CancelScheduledNotification() { Debug.Log("Cancelling scheduled notification with id: " + _notificationId); AGNotificationManager.CancelScheduledNotification(_notificationId); }