Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using OneSignalSDK.DotNet.Android.Utilities;
using OneSignalSDK.DotNet.Android.Utilities;
using OneSignalSDK.DotNet.Core;
using OneSignalSDK.DotNet.Core.Internal.Utilities;
using OneSignalSDK.DotNet.Core.Notifications;
Expand Down Expand Up @@ -40,6 +40,11 @@ public async Task<bool> RequestPermissionAsync(bool fallbackToSettings)
return await consumer;
}

public void ClearAllNotifications()
{
OneSignalNative.Notifications.ClearAllNotifications();
}

private class InternalNotificationsEventsHandler
: Java.Lang.Object,
Com.OneSignal.Android.Notifications.IPermissionObserver,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Security;
using System.Threading.Tasks;
using System.Xml.Linq;
Expand Down Expand Up @@ -65,5 +65,10 @@ public interface INotificationsManager
/// the result is false if the user is opted out of notifications permission(user rejected).
/// </returns>
Task<bool> RequestPermissionAsync(bool fallbackToSettings);

/// <summary>
/// Removes all OneSignal notifications from the Notification Shade.
/// </summary>
void ClearAllNotifications();
}
}
7 changes: 6 additions & 1 deletion OneSignalSDK.DotNet.iOS/iOSNotificationsManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Security.Permissions;
using System.Security.Permissions;
using Com.OneSignal.iOS;
using Foundation;
using OneSignalSDK.DotNet.Core;
Expand Down Expand Up @@ -46,6 +46,11 @@ public async Task<bool> RequestPermissionAsync(bool fallbackToSettings)
return await proxy;
}

public void ClearAllNotifications()
{
OneSignalNative.Notifications.ClearAll();
}

private sealed class InternalNotificationsPermissionObserver
: Com.OneSignal.iOS.OSNotificationPermissionObserver
{
Expand Down
1,194 changes: 219 additions & 975 deletions examples/build.md

Large diffs are not rendered by default.

40 changes: 32 additions & 8 deletions examples/demo/Controls/Sections/SendIamSection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
</Grid>

<!-- TOP BANNER -->
<Border Style="{StaticResource CardBorderStyle}" Padding="0">
<Grid BackgroundColor="{StaticResource OneSignalRed}" ColumnDefinitions="Auto,*" Padding="12">
<Border
BackgroundColor="{StaticResource OneSignalRed}"
StrokeShape="RoundRectangle 8"
StrokeThickness="0"
Padding="12"
HeightRequest="48"
>
<Grid ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTopBannerTapped" />
</Grid.GestureRecognizers>
Expand All @@ -51,8 +57,14 @@
</Border>

<!-- BOTTOM BANNER -->
<Border Style="{StaticResource CardBorderStyle}" Padding="0">
<Grid BackgroundColor="{StaticResource OneSignalRed}" ColumnDefinitions="Auto,*" Padding="12">
<Border
BackgroundColor="{StaticResource OneSignalRed}"
StrokeShape="RoundRectangle 8"
StrokeThickness="0"
Padding="12"
HeightRequest="48"
>
<Grid ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="OnBottomBannerTapped" />
</Grid.GestureRecognizers>
Expand All @@ -77,8 +89,14 @@
</Border>

<!-- CENTER MODAL -->
<Border Style="{StaticResource CardBorderStyle}" Padding="0">
<Grid BackgroundColor="{StaticResource OneSignalRed}" ColumnDefinitions="Auto,*" Padding="12">
<Border
BackgroundColor="{StaticResource OneSignalRed}"
StrokeShape="RoundRectangle 8"
StrokeThickness="0"
Padding="12"
HeightRequest="48"
>
<Grid ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCenterModalTapped" />
</Grid.GestureRecognizers>
Expand All @@ -103,8 +121,14 @@
</Border>

<!-- FULL SCREEN -->
<Border Style="{StaticResource CardBorderStyle}" Padding="0">
<Grid BackgroundColor="{StaticResource OneSignalRed}" ColumnDefinitions="Auto,*" Padding="12">
<Border
BackgroundColor="{StaticResource OneSignalRed}"
StrokeShape="RoundRectangle 8"
StrokeThickness="0"
Padding="12"
HeightRequest="48"
>
<Grid ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="OnFullScreenTapped" />
</Grid.GestureRecognizers>
Expand Down
6 changes: 6 additions & 0 deletions examples/demo/Controls/Sections/SendPushSection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@
Clicked="OnCustomClicked"
AutomationId="send_custom_push_button"
/>
<Button
Text="CLEAR ALL"
Style="{StaticResource OutlineButtonStyle}"
Clicked="OnClearAllClicked"
AutomationId="clear_all_notifications_button"
/>
</VerticalStackLayout>
</ContentView>
5 changes: 5 additions & 0 deletions examples/demo/Controls/Sections/SendPushSection.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ private void OnCustomClicked(object? sender, EventArgs e)
CustomNotificationRequested?.Invoke(this, e);
}

private void OnClearAllClicked(object? sender, EventArgs e)
{
_viewModel?.ClearAllNotifications();
}

private void OnInfoTapped(object? sender, EventArgs e) => InfoTapped?.Invoke(this, e);
}
4 changes: 0 additions & 4 deletions examples/demo/Platforms/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<string>OneSignal Demo</string>
<key>CFBundleIdentifier</key>
<string>com.onesignal.example</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
Expand Down
2 changes: 2 additions & 0 deletions examples/demo/Repositories/OneSignalRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public void TrackEvent(string name, IDictionary<string, object>? properties) =>
public void OptOutPush() => OneSignal.User.PushSubscription.OptOut();

// Notifications
public void ClearAllNotifications() => OneSignal.Notifications.ClearAllNotifications();

public bool HasPermission() => OneSignal.Notifications.Permission;

public Task<bool> RequestPermissionAsync(bool fallbackToSettings) =>
Expand Down
7 changes: 7 additions & 0 deletions examples/demo/ViewModels/AppViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ public async Task SendNotificationAsync(NotificationType type)
);
}

[RelayCommand]
public void ClearAllNotifications()
{
_repository.ClearAllNotifications();
LogManager.Instance.I("AppVM", "All notifications cleared");
}

public async Task SendCustomNotificationAsync(string title, string body)
{
var success = await _repository.SendCustomNotificationAsync(title, body);
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<ApplicationTitle>OneSignal Demo</ApplicationTitle>
<ApplicationId>com.onesignal.example</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>2</ApplicationVersion>
<ApplicationDisplayVersion>3</ApplicationDisplayVersion>

<SupportedOSPlatformVersion
Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'"
Expand Down