4using System.Threading.Tasks;
7using UserNotifications;
23 CancellationToken.ThrowIfCancellationRequested();
28 UNMutableNotificationContent content =
new()
31 Body = Intent.Body ??
string.Empty,
32 Sound = UNNotificationSound.Default,
33 UserInfo = this.BuildUserInfo(Intent)
36 UNNotificationRequest request = UNNotificationRequest.FromIdentifier(
37 Guid.NewGuid().ToString(),
42 await UNUserNotificationCenter.Current.AddNotificationRequestAsync(request);
47 NSMutableDictionary dictionary =
new();
49 if (!
string.IsNullOrEmpty(Intent.
Channel))
50 dictionary.SetValueForKey(
new NSString(Intent.
Channel),
new NSString(
"channelId"));
52 dictionary.SetValueForKey(
new NSString(Intent.
Title),
new NSString(
"myTitle"));
54 if (!
string.IsNullOrEmpty(Intent.
Body))
55 dictionary.SetValueForKey(
new NSString(Intent.
Body),
new NSString(
"myBody"));
57 dictionary.SetValueForKey(
new NSString(Intent.
Action.ToString()),
new NSString(
"action"));
59 if (!
string.IsNullOrEmpty(Intent.
EntityId))
60 dictionary.SetValueForKey(
new NSString(Intent.
EntityId),
new NSString(
"entityId"));
63 dictionary.SetValueForKey(
new NSString(Intent.
CorrelationId),
new NSString(
"correlationId"));
65 foreach (KeyValuePair<string, string> pair
in Intent.
Extras)
67 dictionary.SetValueForKey(
new NSString(pair.Value),
new NSString(pair.Key));
72 string json = JsonSerializer.Serialize(Intent);
73 dictionary.SetValueForKey(
new NSString(json),
new NSString(
"notificationIntent"));
Platform-neutral intent describing how to route a notification.
string? EntityId
Gets or sets an entity identifier associated with the action.
string? CorrelationId
Gets or sets an optional correlation identifier.
string? Body
Gets or sets the message body to display.
string Title
Gets or sets the title to display.
NotificationPresentation Presentation
Gets or sets how the notification should be presented.
NotificationAction Action
Gets or sets the intended action.
string? Channel
Gets or sets the push channel identifier.
Dictionary< string, string > Extras
Gets or sets extra data used for routing.
Renders local notifications on iOS.
async Task RenderAsync(NotificationIntent Intent, CancellationToken CancellationToken)
Displays a local notification with the provided intent.
Renders local notifications on the platform.
NotificationPresentation
Presentation preference for a notification intent.