Skip to content

Commit 626cdfa

Browse files
committed
chore(demo): add clear all notifications button
1 parent f4af573 commit 626cdfa

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public void SendOutcomeWithValue(string name, float value) =>
7070

7171
public void OptOutPush() => OneSignal.User.PushSubscription.OptOut();
7272

73+
public void ClearAllNotifications() => OneSignal.Notifications.ClearAllNotifications();
74+
7375
public bool HasPermission() => OneSignal.Notifications.Permission;
7476

7577
public Task<bool> RequestPermissionAsync(bool fallbackToSettings) =>

examples/demo/Assets/Scripts/UI/Sections/SendPushSectionController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ private VisualElement BuildSection()
5353
)
5454
);
5555

56+
section.Add(
57+
SectionBuilder.CreateDestructiveButton(
58+
"CLEAR ALL",
59+
"clear_all_notifications",
60+
() => _viewModel.ClearAllNotifications()
61+
)
62+
);
63+
5664
return section;
5765
}
5866
}

examples/demo/Assets/Scripts/ViewModels/AppViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,13 @@ public async void SendNotification(NotificationType type)
338338
}
339339
}
340340

341+
public void ClearAllNotifications()
342+
{
343+
_repository.ClearAllNotifications();
344+
LogManager.Instance.Info(Tag, "All notifications cleared");
345+
ShowToast("All notifications cleared");
346+
}
347+
341348
public async void SendCustomNotification(string title, string body)
342349
{
343350
try

0 commit comments

Comments
 (0)