Skip to content

Commit 546c744

Browse files
Set options over explicit method.
1 parent 454ac73 commit 546c744

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

sample/Sample.Android/Resources/Resource.designer.cs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/Notifo.SDK/INotifoMobilePush.ios.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ public partial interface INotifoMobilePush
3030
/// <summary>
3131
/// Method for pulling pending notifications.
3232
/// </summary>
33-
/// <param name="options">The options for handling the pending notifications pull refresh request.</param>
3433
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
35-
Task DidReceivePullRefreshRequestAsync(PullRefreshOptions? options = null);
34+
Task DidReceivePullRefreshRequestAsync();
3635

3736
/// <summary>
3837
/// Method for processing the user's response to a delivered notification.
3938
/// </summary>
4039
/// <param name="response">The user's response to the notification.</param>
4140
void DidReceiveNotificationResponse(UNNotificationResponse response);
41+
42+
/// <summary>
43+
/// Sets the options that are used when new notifications are pulled.
44+
/// </summary>
45+
/// <param name="refreshOptions">The options.</param>
46+
/// <returns>The current instance.</returns>
47+
INotifoMobilePush SetRefreshOptions(PullRefreshOptions refreshOptions);
4248
}

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ namespace Notifo.SDK.NotifoMobilePush;
2121

2222
internal partial class NotifoMobilePushImplementation : NSObject
2323
{
24+
private PullRefreshOptions refreshOptions;
2425
private INotificationHandler? notificationHandler;
2526

27+
/// <inheritdoc />
28+
public INotifoMobilePush SetRefreshOptions(PullRefreshOptions refreshOptions)
29+
{
30+
this.refreshOptions = refreshOptions ?? new PullRefreshOptions();
31+
return this;
32+
}
33+
2634
/// <inheritdoc />
2735
public INotifoMobilePush SetNotificationHandler(INotificationHandler? notificationHandler)
2836
{
@@ -53,29 +61,24 @@ public async Task DidReceiveNotificationRequestAsync(UNNotificationRequest reque
5361
}
5462

5563
/// <inheritdoc />
56-
public async Task DidReceivePullRefreshRequestAsync(PullRefreshOptions? options = null)
64+
public async Task DidReceivePullRefreshRequestAsync()
5765
{
58-
options ??= new PullRefreshOptions();
59-
6066
// iOS does not maintain a queue of undelivered notifications, therefore we have to query here.
61-
var notifications = await GetPendingNotificationsAsync(options.Take, options.Period, default);
67+
var notifications = await GetPendingNotificationsAsync(refreshOptions.Take, refreshOptions.Period, default);
6268

6369
foreach (var notification in notifications)
6470
{
65-
if (options.RaiseEvent)
71+
if (refreshOptions.RaiseEvent)
6672
{
6773
OnReceived(new NotificationEventArgs(notification));
6874
}
6975

70-
if (notification.Silent)
76+
if (notification.Silent || !refreshOptions.PresentNotification)
7177
{
7278
continue;
7379
}
7480

75-
if (options.PresentNotification)
76-
{
77-
await ShowLocalNotificationAsync(notification);
78-
}
81+
await ShowLocalNotificationAsync(notification);
7982
}
8083

8184
await TrackNotificationsAsync(notifications.ToArray());

sdk/Notifo.SDK/PullRefreshOptions.ios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Notifo.SDK;
1212
/// <summary>
1313
/// Options for handling the pending notifications pull refresh request.
1414
/// </summary>
15-
public class PullRefreshOptions
15+
public sealed class PullRefreshOptions
1616
{
1717
/// <summary>
1818
/// The pull refresh request should raise the received event. Default: true.

0 commit comments

Comments
 (0)