diff --git a/MIGRATION_GUIDE_v3_to_v5.md b/MIGRATION_GUIDE_v3_to_v5.md
index 92d630658..14f190ba4 100644
--- a/MIGRATION_GUIDE_v3_to_v5.md
+++ b/MIGRATION_GUIDE_v3_to_v5.md
@@ -103,7 +103,7 @@ To observe changes to the onesignalId or externalId you can add a custom method
OneSignal.User.Changed += _userStateChanged;
- private void yourOnUserStateChangedMethod(object sender, UserStateChangedEventArgs e) {
+ private void _userStateChanged(object sender, UserStateChangedEventArgs e) {
...
}
@@ -173,6 +173,8 @@ The user name space is accessible via `OneSignal.User` and provides access to us
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `IPushSubscription PushSubscription` | *The push subscription associated to the current user.* |
| `string Language` | *Set the 2-character language either as a detected language or explicitly set for this user.* |
+| `string OneSignalId` | *The UUID generated by OneSignal to represent a user, empty if this is currently unavailable.* |
+| `string ExternalId` | *The External ID is OneSignal's default and recommended alias label. This should be the mainidentifier you use to identify users. It is set when calling the [OneSignal.login] method.* |
| `Changed`
`event EventHandler Changed`
`UserStateChangedEventArgs { UserChangedState State }` | *Adds a change event that will run whenever the onesignalId or externalId has been changed.* |
* |
| `PushSubsription.Changed`
`event EventHandler Changed`
`PushSubscriptionChangedEventArgs { PushSubscriptionChangedState State }` | *Adds a change event that will run whenever the push subscription has been changed.* |
diff --git a/OneSignalExample/Assets/OneSignal/CHANGELOG.md b/OneSignalExample/Assets/OneSignal/CHANGELOG.md
index 5d6f5364c..1206f0c2c 100644
--- a/OneSignalExample/Assets/OneSignal/CHANGELOG.md
+++ b/OneSignalExample/Assets/OneSignal/CHANGELOG.md
@@ -7,12 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- iOS crash when calling OneSignal.User.PushSubscription.Id and OneSignal.User.PushSubscription.Token when they are null.
-
-## [5.1.0]
-### Fixed
-- Add getters for the user state that includes onesignalId and externalId
-- Add observer for the user state
### Changed
+- Add public getters for OnesignalId and ExternalId in the User namespace
+- Add public event handler OneSignal.User.Changed that fires when the OnesignalId or ExternalId changes
- Updated included Android SDK to [5.1.4](https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/5.1.4)
## [5.0.6]
diff --git a/OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs b/OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs
index 1b12e606e..22e20a8d8 100644
--- a/OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs
+++ b/OneSignalExample/Assets/OneSignal/Example/OneSignalExampleBehaviour.cs
@@ -34,7 +34,6 @@
using OneSignalSDK.Notifications;
using OneSignalSDK.InAppMessages;
using OneSignalSDK.User;
-using OneSignalSDK.User.Internal;
using OneSignalSDK.User.Models;
using OneSignalSDK.Debug.Models;
using OneSignalSDK.Debug.Utilities;
@@ -215,8 +214,8 @@ private void _pushSubscriptionChanged(object sender, PushSubscriptionChangedEven
}
private void _userStateChanged(object sender, UserStateChangedEventArgs e) {
- _log($"onesignalId changed : {e.State.Current.onesignalId}");
- _log($"externalId changed : {e.State.Current.externalId}");
+ _log($"onesignalId changed : {e.State.Current.OneSignalId}");
+ _log($"externalId changed : {e.State.Current.ExternalId}");
}
/*
diff --git a/com.onesignal.unity.android/Runtime/AndroidUserManager.cs b/com.onesignal.unity.android/Runtime/AndroidUserManager.cs
index 8a9dd860e..bd4e9b16a 100644
--- a/com.onesignal.unity.android/Runtime/AndroidUserManager.cs
+++ b/com.onesignal.unity.android/Runtime/AndroidUserManager.cs
@@ -117,7 +117,6 @@ public InternalUserChangedHandler(AndroidUserManager userManager) : base("user.s
/// UserChangedState
public void onUserStateChange(AndroidJavaObject state) {
- UnityEngine.Debug.Log("onUserStateChange fired");
var currentJO = state.Call("getCurrent");
var current = currentJO.ToSerializable();
diff --git a/com.onesignal.unity.core/Runtime/User/Internal/UserState.cs b/com.onesignal.unity.core/Runtime/User/Internal/UserState.cs
index 199ac2c5b..eab372c57 100644
--- a/com.onesignal.unity.core/Runtime/User/Internal/UserState.cs
+++ b/com.onesignal.unity.core/Runtime/User/Internal/UserState.cs
@@ -30,8 +30,13 @@
namespace OneSignalSDK.User.Internal {
[Serializable] public sealed class UserState {
- public string onesignalId;
- public string externalId;
+ public string OneSignalId => onesignalId;
+ public string ExternalId => externalId;
+
+ #region Native Field Handling
+ public string onesignalId;
+ public string externalId;
+ #endregion
public UserState(string onesignalId, string externalId) {
this.onesignalId = onesignalId;
diff --git a/com.onesignal.unity.core/Runtime/User/Models/IPushSubscription.cs b/com.onesignal.unity.core/Runtime/User/Models/IPushSubscription.cs
index 378a948f6..fabdc919f 100644
--- a/com.onesignal.unity.core/Runtime/User/Models/IPushSubscription.cs
+++ b/com.onesignal.unity.core/Runtime/User/Models/IPushSubscription.cs
@@ -25,10 +25,10 @@
* THE SOFTWARE.
*/
+using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
-using System;
namespace OneSignalSDK.User.Models {
///
diff --git a/com.onesignal.unity.core/Runtime/User/IUserState.cs b/com.onesignal.unity.core/Runtime/User/Models/IUserState.cs
similarity index 92%
rename from com.onesignal.unity.core/Runtime/User/IUserState.cs
rename to com.onesignal.unity.core/Runtime/User/Models/IUserState.cs
index 84fdca9de..3f5e31bc3 100644
--- a/com.onesignal.unity.core/Runtime/User/IUserState.cs
+++ b/com.onesignal.unity.core/Runtime/User/Models/IUserState.cs
@@ -32,15 +32,15 @@ public interface IUserState {
///
/// The unique identifier for your OneSignal account. This will be an empty string until the
/// user has been successfully logged in on the backend and assigned an ID.
- /// Use [addObserver] to be notified when the [onesignalId] has been successfully assigned.
+ /// Use [addObserver] to be notified when the [OnesignalId] has been successfully assigned.
///
- string onesignalId { get; }
+ string OneSignalId { get; }
///
/// The external identifier that you use to identify users. Use [addObserver] to be notified
/// when the [externalId] has been successfully assigned. This will be an empty string if no
- /// external identifier has been assigned to the associated [onesignalId].
+ /// external identifier has been assigned to the associated [OnesignalId].
///
- string externalId { get; }
+ string ExternalId { get; }
}
}
\ No newline at end of file
diff --git a/com.onesignal.unity.core/Runtime/User/IUserState.cs.meta b/com.onesignal.unity.core/Runtime/User/Models/IUserState.cs.meta
similarity index 100%
rename from com.onesignal.unity.core/Runtime/User/IUserState.cs.meta
rename to com.onesignal.unity.core/Runtime/User/Models/IUserState.cs.meta
diff --git a/com.onesignal.unity.core/Runtime/User/UserChangedState.cs b/com.onesignal.unity.core/Runtime/User/Models/UserChangedState.cs
similarity index 100%
rename from com.onesignal.unity.core/Runtime/User/UserChangedState.cs
rename to com.onesignal.unity.core/Runtime/User/Models/UserChangedState.cs
diff --git a/com.onesignal.unity.core/Runtime/User/UserChangedState.cs.meta b/com.onesignal.unity.core/Runtime/User/Models/UserChangedState.cs.meta
similarity index 100%
rename from com.onesignal.unity.core/Runtime/User/UserChangedState.cs.meta
rename to com.onesignal.unity.core/Runtime/User/Models/UserChangedState.cs.meta