Skip to content

Commit

Permalink
Merge pull request #741 from OneSignal/fix/multipleOneSignalInstance
Browse files Browse the repository at this point in the history
[Fix]Multiple OneSignal instance
  • Loading branch information
shepherd-l authored Jul 3, 2024
2 parents d5650a4 + aa776fd commit 65abdaa
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 156 deletions.
3 changes: 3 additions & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Additional instance of OneSignal error when calling OneSignal methods in Awake()

## [5.1.6]
### Fixed
- iOS build error: No type or protocol named OSLiveActivities
Expand Down
4 changes: 3 additions & 1 deletion com.onesignal.unity.android/Runtime/OneSignalAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public sealed partial class OneSignalAndroid : OneSignalPlatform {
/// Used to provide a reference for the global callbacks
/// </summary>
public OneSignalAndroid() {
if (_instance != null)
if (_instance != null) {
SDKDebug.Error("Additional instance of OneSignalAndroid created.");
return;
}

_instance = this;
_debug = new AndroidDebugManager(_sdkClass);
Expand Down
42 changes: 0 additions & 42 deletions com.onesignal.unity.android/Runtime/OneSignalAndroidInit.cs

This file was deleted.

This file was deleted.

39 changes: 0 additions & 39 deletions com.onesignal.unity.core/Editor/Platform/OneSignalNativeInit.cs

This file was deleted.

This file was deleted.

6 changes: 2 additions & 4 deletions com.onesignal.unity.core/Runtime/OneSignal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ public static partial class OneSignal {
/// The default static instance of the OneSignal Unity SDK
/// </summary>
public static OneSignalPlatform Default {
private get => _getDefaultInstance();
set {
UnityEngine.Debug.Log($"[OneSignal] OneSignal set to platform SDK {value.GetType()}. Current version is {Version}");
_default = value;
get {
return _getDefaultInstance();
}
}

Expand Down
2 changes: 0 additions & 2 deletions com.onesignal.unity.core/Runtime/OneSignalPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ public abstract class OneSignalPlatform {
internal static event Action<string> OnInitialize;

internal static string AppId { get; private set; }
internal static bool DidInitialize { get; private set; }

protected static void _completedInit(string appId) {
AppId = appId;
DidInitialize = true;
OnInitialize?.Invoke(AppId);
}

Expand Down
4 changes: 3 additions & 1 deletion com.onesignal.unity.ios/Runtime/OneSignaliOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ public sealed partial class OneSignaliOS : OneSignalPlatform {
/// Used to provide a reference for and sets up the global callbacks
/// </summary>
public OneSignaliOS() {
if (_instance != null)
if (_instance != null) {
SDKDebug.Error("Additional instance of OneSignaliOS created.");
return;
}

_instance = this;
_debug = new iOSDebugManager();
Expand Down
42 changes: 0 additions & 42 deletions com.onesignal.unity.ios/Runtime/OneSignaliOSInit.cs

This file was deleted.

11 changes: 0 additions & 11 deletions com.onesignal.unity.ios/Runtime/OneSignaliOSInit.cs.meta

This file was deleted.

0 comments on commit 65abdaa

Please sign in to comment.