Skip to content

Commit 1b7b515

Browse files
committed
Remove async from clearAll and requestPermission
Removed async from Notifications.ClearAllNotifications and Location.RequestPermission to match native inconsistency with method signatures
1 parent f059055 commit 1b7b515

File tree

9 files changed

+17
-35
lines changed

9 files changed

+17
-35
lines changed

OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ public async void PromptForPush() {
306306
_log($"Notification permission is: {OneSignal.Default.Notifications.Permission}");
307307
}
308308

309-
public async void ClearPush() {
310-
_log("Clearing existing OneSignal push notifications and awaiting result ...");
309+
public void ClearPush() {
310+
_log("Clearing existing OneSignal push notifications");
311311

312-
await OneSignal.Default.Notifications.ClearAllNotificationsAsync();
312+
OneSignal.Default.Notifications.ClearAllNotifications();
313313

314314
_log("Notifications cleared");
315315
}
@@ -375,15 +375,10 @@ public void AddOutcomeWithValue() {
375375
* Location
376376
*/
377377

378-
public async void PromptLocation() {
379-
_log("Opening permission prompt for location and awaiting result...");
378+
public void PromptLocation() {
379+
_log("Opening permission prompt for location");
380380

381-
var result = await OneSignal.Default.Location.RequestPermissionAsync();
382-
383-
if (result)
384-
_log("User opted in");
385-
else
386-
_log("User opted out");
381+
OneSignal.Default.Location.RequestPermission();
387382
}
388383

389384
public void ToggleShareLocation() {

com.onesignal.unity.android/Runtime/AndroidLocationManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ public bool IsShared {
4545
set => _location.Call("setShared", value);
4646
}
4747

48-
public async Task<bool> RequestPermissionAsync() {
48+
public void RequestPermission() {
4949
var continuation = new BoolContinuation();
5050
_location.Call<AndroidJavaObject>("requestPermission", continuation.Proxy);
51-
return await continuation;
5251
}
5352
}
5453
}

com.onesignal.unity.android/Runtime/AndroidNotificationsManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ public async Task<bool> RequestPermissionAsync(bool fallbackToSettings) {
5454
return await continuation;
5555
}
5656

57-
public async Task ClearAllNotificationsAsync() {
57+
public void ClearAllNotifications() {
5858
var continuation = new Continuation();
5959
_notifications.Call<AndroidJavaObject>("clearAllNotifications", continuation.Proxy);
60-
await continuation;
6160
}
6261

6362
public void Initialize() {

com.onesignal.unity.core/Editor/Platform/LocationManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace OneSignalSDKNew.Location {
3131
internal sealed class LocationManager : ILocationManager {
3232
public bool IsShared { get; set; }
3333

34-
public Task<bool> RequestPermissionAsync() {
35-
return Task.FromResult(false);
34+
public void RequestPermission() {
35+
3636
}
3737
}
3838
}

com.onesignal.unity.core/Editor/Platform/NotificationsManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public Task<bool> RequestPermissionAsync(bool fallbackToSettings){
4040
return Task.FromResult(false);
4141
}
4242

43-
public Task ClearAllNotificationsAsync() {
44-
return Task.CompletedTask;
43+
public void ClearAllNotifications() {
44+
4545
}
4646
}
4747
}

com.onesignal.unity.core/Runtime/Location/ILocationManager.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ public interface ILocationManager {
4141
/// <summary>
4242
/// Helper method to show the native prompt to ask the user for consent to share their location
4343
/// </summary>
44-
/// <param name="fallbackToSettings">
45-
/// Whether to direct the user to this app's settings to drive enabling of notifications,
46-
/// when the in-app prompting is not possible.
47-
/// </param>
48-
/// <returns>
49-
/// Awaitable boolean of true if the user opted in to location permission or
50-
/// false if the user is opted out of location permission
51-
/// </returns>
52-
Task<bool> RequestPermissionAsync();
44+
void RequestPermission();
5345
}
5446
}

com.onesignal.unity.core/Runtime/Notifications/INotificationsManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ public interface INotificationsManager {
8989
Task<bool> RequestPermissionAsync(bool fallbackToSettings);
9090

9191
/// <summary>
92-
/// Removes all OneSignal app notifications from the Notification Shade
92+
/// Removes all OneSignal app notifications
9393
/// </summary>
94-
/// <remarks>Android Only</remarks>
95-
Task ClearAllNotificationsAsync();
94+
void ClearAllNotifications();
9695
}
9796
}

com.onesignal.unity.ios/Runtime/iOSLocationManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public bool IsShared {
4141
set => _locationSetIsShared(value);
4242
}
4343

44-
public Task<bool> RequestPermissionAsync() { // iOS make async
44+
public void RequestPermission() { // iOS make async
4545
_locationRequestPermission();
46-
return Task.FromResult(true);
4746
}
4847
}
4948
}

com.onesignal.unity.ios/Runtime/iOSNotificationsManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public async Task<bool> RequestPermissionAsync(bool fallbackToSettings) {
7171
return await proxy;
7272
}
7373

74-
public Task ClearAllNotificationsAsync() {
74+
public void ClearAllNotifications() {
7575
_notificationsClearAll();
76-
return Task.CompletedTask;
7776
}
7877

7978
public void Initialize() {

0 commit comments

Comments
 (0)