Skip to content

Commit 98dfefa

Browse files
More comments.
1 parent 2a8eb69 commit 98dfefa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sdk/Notifo.SDK/NotifoMobilePush/NotifoMobilePushImplementation.ios.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public async Task DidReceivePullRefreshRequestAsync(PullRefreshOptions? options
5252
{
5353
options ??= new PullRefreshOptions();
5454

55+
// iOS does not maintain a queue of undelivered notifications, therefore we have to query here.
5556
var notifications = await GetPendingNotificationsAsync(options.Take, options.Period);
5657

5758
foreach (var notification in notifications)
@@ -89,6 +90,7 @@ private async Task<IEnumerable<UserNotificationDto>> GetPendingNotificationsAsyn
8990
var currentSeen = await GetSeenNotificationsAsync();
9091
var currentTime = DateTimeOffset.UtcNow;
9192

93+
// Only take the recent notifications into account (default: 3 days).
9294
bool IsRecent(DateTimeOffset date)
9395
{
9496
return (currentTime - date.UtcDateTime) <= maxAge;

sdk/Notifo.SDK/NotifoMobilePush/NotifoMobilePushImplementation.tracking.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ public async Task TrackNotificationsAsync(params Guid[] ids)
5353
{
5454
var set = await LoadSeenNotificationsAsync();
5555

56+
// Store the seen notifications immediately as a cache, if the actual command to the server fails.
5657
await seenNotificationsStore.AddSeenNotificationIdsAsync(Capacity, ids);
5758

5859
foreach (var id in ids)
5960
{
6061
set.Add(id, Capacity);
6162
}
6263

64+
// Track all notifications with one HTTP request.
6365
commandQueue.Run(new TrackSeenCommand { Ids = ids.ToHashSet(), Token = token });
6466
}
6567
catch (Exception ex)
@@ -75,12 +77,8 @@ public async Task TrackNotificationsAsync(params Guid[] ids)
7577

7678
private async Task<SlidingSet<Guid>> LoadSeenNotificationsAsync()
7779
{
78-
if (seenNotifications == null)
79-
{
80-
seenNotifications = await seenNotificationsStore.GetSeenNotificationIdsAsync();
81-
}
82-
83-
return seenNotifications;
80+
// Only query the notifications once and then hold everything in-memory.
81+
return seenNotifications ??= await seenNotificationsStore.GetSeenNotificationIdsAsync();
8482
}
8583
}
8684
}

0 commit comments

Comments
 (0)