forked from shinyorg/shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
src/Shiny.Notifications/Platforms/iOS/PlatformExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Foundation; | ||
using UserNotifications; | ||
|
||
|
||
namespace Shiny.Notifications | ||
{ | ||
static class PlatformExtensions | ||
public static class PlatformExtensions | ||
{ | ||
public static Notification FromNative(this UNNotificationRequest native) | ||
{ | ||
if (!Int32.TryParse(native.Identifier, out var i)) | ||
return null; | ||
|
||
var shiny = new Notification | ||
{ | ||
Id = i, | ||
Title = native.Content?.Title, | ||
Message = native.Content?.Body, | ||
Sound = native.Content.Sound?.ToString(), | ||
//Metadata = native.Content.UserInfo.FromNsDictionary() | ||
}; | ||
|
||
if (native.Trigger is UNCalendarNotificationTrigger calendar) | ||
shiny.ScheduleDate = calendar.NextTriggerDate?.ToDateTime() ?? DateTime.Now; | ||
// if null, it is firing and it is firing right now | ||
|
||
return shiny; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters