You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION_GUIDE_v3_to_v5.md
+29-28Lines changed: 29 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -31,38 +31,38 @@ OneSignal uses a built-in **alias label** called `external_id` which supports ex
31
31
32
32
The OneSignal SDK has been updated to be more modular in nature. The SDK has been split into namespaces and functionality previously in the static `OneSignal.Default` class has been moved to the appropriate namespace. The namespaces, their containing modules, and how to access them in code are as follows:
Initialization of the OneSignal SDK, although similar to past versions, has changed. The target OneSignal application (`appId`) is now provided as part of initialization and cannot be changed post-initialization. A typical initialization now looks similar to below
49
49
50
-
OneSignal.Default.Initialize(ONESIGNAL_APP_ID);
50
+
OneSignal.Initialize(ONESIGNAL_APP_ID);
51
51
// RequestPermissionAsync will show the native platform notification permission prompt.
52
52
// We recommend removing the following code and instead using an In-App Message to prompt for notification permission.
53
-
var result = await OneSignal.Default.Notifications.RequestPermissionAsync(true);
53
+
var result = await OneSignal.Notifications.RequestPermissionAsync(true);
54
54
55
55
If your integration is not user-centric, there is no additional startup code required. A user is automatically created as part of the push subscription creation, both of which are only accessible from the current device and the OneSignal dashboard.
56
56
57
57
If your integration is user-centric, or you want the ability to identify as the same user on multiple devices, the OneSignal SDK should be called once the user has been identified:
58
58
59
-
OneSignal.Default.Login("USER_EXTERNAL_ID");
59
+
OneSignal.Login("USER_EXTERNAL_ID");
60
60
61
61
The `login` method will associate the device’s push subscription to the user that can be identified via alias `externalId=USER_EXTERNAL_ID`. If a user with the provided `externalId` does not exist, one will be created. If a user does already exist, the user will be updated to include the current device’s push subscription. Note that a device's push subscription will always be transferred to the currently logged in user, as they represent the current owners of that push subscription.
62
62
63
63
Once (or if) the user is no longer identifiable in your app (i.e. they logged out), the OneSignal SDK should be called:
64
64
65
-
OneSignal.Default.Logout();
65
+
OneSignal.Logout();
66
66
67
67
Logging out has the affect of reverting to a “device-scoped” user, which is the new owner of the device’s push subscription.
68
68
@@ -74,7 +74,7 @@ In previous versions of the SDK there was a player that could have zero or one e
74
74
**Push Subscription**
75
75
The current device’s push subscription can be retrieved via:
76
76
77
-
var pushSubscription = OneSignal.Default.User.PushSubscription;
77
+
var pushSubscription = OneSignal.User.PushSubscription;
78
78
79
79
80
80
If at any point you want the user to stop receiving push notifications on the current device (regardless of permission status) you can use the push subscription to opt out:
@@ -91,14 +91,14 @@ To resume receiving of push notifications (driving the native permission prompt
91
91
Email and/or SMS subscriptions can be added or removed via:
@@ -107,7 +107,7 @@ Email and/or SMS subscriptions can be added or removed via:
107
107
Below is a comprehensive reference to the v5.0.0 OneSignal SDK.
108
108
109
109
**OneSignal**
110
-
The SDK is still accessible via a `OneSignal.Default` static class, it provides access to higher level functionality and is a gateway to each subspace of the SDK.
110
+
The SDK is still accessible via a `OneSignal` static class, it provides access to higher level functionality and is a gateway to each subspace of the SDK.
|`bool Permission`|*Whether this app has push notification permission.*|
160
+
|`bool CanRequestPermission`|*Whether this app can request push notification permission.*|
160
161
|`NotificationPermission PermissionNative`|*Native permission of the device. The enum NotificationPermission can be NotDetermined, Denied, Authorized, Provisional, or Ephemeral.*|
161
162
|`Task<bool> RequestPermissionAsync(bool fallbackToSettings)`|*Prompt the user for permission to push notifications. This will display the native OS prompt to request push notification permission. If the user enables, a push subscription to this device will be automatically added to the user.*|
162
163
|`void ClearAllNotifications()`|*Removes all OneSignal notifications.*|
@@ -166,7 +167,7 @@ The notification namespace is accessible via `OneSignal.Default.Notifications` a
166
167
167
168
168
169
**Location Namespace**
169
-
The location namespace is accessible via `OneSignal.Default.Location` and provides access to location-scoped functionality.
170
+
The location namespace is accessible via `OneSignal.Location` and provides access to location-scoped functionality.
0 commit comments