Skip to content
Open
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
11 changes: 6 additions & 5 deletions com.onesignal.unity.android/Runtime/OneSignalAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ public override bool ConsentRequired

public override void Initialize(string appId)
{
if (InputGuard.IsMissing(appId, "initialize: appId"))
return;
Comment on lines -133 to -134

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: with this guard gone, _completedInit(appId) at the end of Initialize now runs when appId is null or "". It sets OneSignalPlatform.AppId to that and fires OnInitialize(null), so the attribution hook sends a null app id. Maybe skip _completedInit when appId is missing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real gap, not fixed. Holding with the rest of the set until the flag rollout, so it gets done once rather than patched blind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now fixed in 0cfd95f. _completedInit only runs when the app id is non-empty, so OnInitialize no longer gets a value the SDK is not using.

var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

Expand Down Expand Up @@ -175,7 +173,12 @@ public override void Initialize(string appId)
_liveActivities = new AndroidLiveActivitiesManager();
}

_completedInit(appId);
// Native may have resolved a cached app id instead of the one passed in, so publishing
// a missing value here would hand OnInitialize an AppId the SDK is not using.
if (!string.IsNullOrEmpty(appId))
{
_completedInit(appId);
}
}

/// <summary>
Expand All @@ -201,8 +204,6 @@ private static void _enableHardwareAcceleration(AndroidJavaObject activity)

public override void Login(string externalId, string jwtBearerToken = null)
{
if (InputGuard.IsMissing(externalId, "login: externalId"))
return;
_sdkClass.CallStatic("login", externalId, jwtBearerToken);
}

Expand Down
4 changes: 4 additions & 0 deletions com.onesignal.unity.ios/Runtime/OneSignaliOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public override bool ConsentRequired

public override void Initialize(string appId)
{
// Native initialize: does handle nil, but it rejects "" without falling back to the
// cached app id, so an empty value still has to stop here.
if (InputGuard.IsMissing(appId, "initialize: appId"))
return;
_oneSignalInitialize(appId);
Expand Down Expand Up @@ -185,6 +187,8 @@ public override void Initialize(string appId)

public override void Login(string externalId, string jwtBearerToken = null)
{
// Native iOS login forwards externalId into a non-optional Swift parameter with no
// nil handling, so this guard is what keeps a null from reaching it.
if (InputGuard.IsMissing(externalId, "login: externalId"))
return;
if (string.IsNullOrWhiteSpace(jwtBearerToken))
Expand Down