Skip to content

Commit

Permalink
Fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jinliu9508 committed Feb 13, 2024
1 parent d57c900 commit a1e313e
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
...
}

Expand Down Expand Up @@ -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` <br><br> `event EventHandler<UserStateChangedEventArgs> Changed` <br><br> `UserStateChangedEventArgs { UserChangedState State }` | *Adds a change event that will run whenever the onesignalId or externalId has been changed.* |
* |
| `PushSubsription.Changed` <br><br> `event EventHandler<PushSubscriptionChangedEventArgs> Changed` <br><br> `PushSubscriptionChangedEventArgs { PushSubscriptionChangedState State }` | *Adds a change event that will run whenever the push subscription has been changed.* |
Expand Down
7 changes: 2 additions & 5 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}");
}

/*
Expand Down
1 change: 0 additions & 1 deletion com.onesignal.unity.android/Runtime/AndroidUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public InternalUserChangedHandler(AndroidUserManager userManager) : base("user.s

/// <param name="state">UserChangedState</param>
public void onUserStateChange(AndroidJavaObject state) {
UnityEngine.Debug.Log("onUserStateChange fired");
var currentJO = state.Call<AndroidJavaObject>("getCurrent");
var current = currentJO.ToSerializable<UserState>();

Expand Down
9 changes: 7 additions & 2 deletions com.onesignal.unity.core/Runtime/User/Internal/UserState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using System;

namespace OneSignalSDK.User.Models {
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public interface IUserState {
/// <summary>
/// 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.
/// </summary>
string onesignalId { get; }
string OneSignalId { get; }

/// <summary>
/// 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].
/// </summary>
string externalId { get; }
string ExternalId { get; }
}
}

0 comments on commit a1e313e

Please sign in to comment.