Skip to content

Commit

Permalink
Merge pull request #583 from OneSignal/update-sdk-namespace
Browse files Browse the repository at this point in the history
[User Model] Update SDK namespace
  • Loading branch information
shepherd-l authored Feb 3, 2023
2 parents d785ad4 + 6b66d0c commit b9c675c
Show file tree
Hide file tree
Showing 112 changed files with 15,706 additions and 3,146 deletions.
File renamed without changes.
209 changes: 209 additions & 0 deletions MIGRATION_GUIDE_v3_to_v5.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"versionDefines": [
{
"name": "com.onesignal.unity.core",
"expression": "3.0.0-beta.1",
"expression": "3.0.0",
"define": "ONE_SIGNAL_INSTALLED"
}
],
Expand Down
7 changes: 7 additions & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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]
### Changed
- Overhauled public API of the SDK to a user-centered model. While this release is in beta please see our included [example MonoBehaviour](Example/OneSignalExampleBehaviour.cs) for usage.
- Updated included Android SDK to [5.0.0-beta1](https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/5.0.0-beta1)
- Updated included iOS SDK to [5.0.0-beta-01](https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/5.0.0-beta-01)

If you run into any problems, please don’t hesitate to [open an issue](https://github.com/OneSignal/OneSignal-Unity-SDK/issues/new)!

## [3.0.9]
### Fixed
- Android - Lock OneSignal version so it doesn't get bumped to the next major version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void OnEnable() {
if (Activator.CreateInstance(stepType) is OneSignalSetupStep step)
steps.Add(step);
else
Debug.LogWarning($"could not create setup step from type {stepType.Name}");
UnityEngine.Debug.LogWarning($"could not create setup step from type {stepType.Name}");
}

_setupSteps = steps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

#if ONE_SIGNAL_INSTALLED
using System;
using OneSignalSDKNew; // TODO: Change namespace and delete MiniJson copy, OneSignalExampleBehaviourOld, OneSignalExampleSceneOld
using OneSignalSDK;
using UnityEngine;
using UnityEngine.UI;
using OneSignalSDKNew.Debug.Utilities;
using OneSignalSDKNew.Debug.Models;
using OneSignalSDKNew.Notifications.Models;
using OneSignalSDKNew.InAppMessages.Models;
using OneSignalSDKNew.User.Models;
using OneSignalSDK.Debug.Utilities;
using OneSignalSDK.Debug.Models;
using OneSignalSDK.Notifications.Models;
using OneSignalSDK.InAppMessages.Models;
using OneSignalSDK.User.Models;
using System.Collections.Generic;

// ReSharper disable InconsistentNaming
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'com.android.library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'com.onesignal:OneSignal:4.8.3' // Packages/com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml:6
implementation 'com.onesignal:OneSignal:5.0.0-beta1' // Packages/com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml:6
// Android Resolver Dependencies End
**DEPS**}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<packages>
<package>com.onesignal:OneSignal:4.8.3</package>
<package>com.onesignal:OneSignal:5.0.0-beta1</package>
</packages>
<files />
<settings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<repositories>
<repository>https://repo.maven.apache.org/maven2</repository>
</repositories>
<androidPackage spec="com.onesignal:OneSignal:5.0.0-alpha1" />
<androidPackage spec="com.onesignal:OneSignal:5.0.0-beta1" />
</androidPackages>
</dependencies>
6 changes: 3 additions & 3 deletions com.onesignal.unity.android/Runtime/AndroidDebugManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
*/

using UnityEngine;
using OneSignalSDKNew.Debug;
using OneSignalSDKNew.Debug.Models;
using OneSignalSDK.Debug;
using OneSignalSDK.Debug.Models;

namespace OneSignalSDKNew.Android.Debug {
namespace OneSignalSDK.Android.Debug {
internal sealed class AndroidDebugManager : IDebugManager {
private readonly AndroidJavaObject _debug;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

using UnityEngine;
using System.Collections.Generic;
using OneSignalSDKNew.InAppMessages;
using OneSignalSDKNew.InAppMessages.Models;
using OneSignalSDKNew.Android.Utilities;
using OneSignalSDK.InAppMessages;
using OneSignalSDK.InAppMessages.Models;
using OneSignalSDK.Android.Utilities;

namespace OneSignalSDKNew.Android.InAppMessages {
namespace OneSignalSDK.Android.InAppMessages {
internal sealed class AndroidInAppMessagesManager : IInAppMessagesManager {
private readonly AndroidJavaObject _inAppMessages;

Expand Down
8 changes: 3 additions & 5 deletions com.onesignal.unity.android/Runtime/AndroidLocationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

using UnityEngine;
using System.Threading.Tasks;
using OneSignalSDKNew.Location;
using OneSignalSDKNew.Android.Utilities;
using OneSignalSDK.Location;
using OneSignalSDK.Android.Utilities;

using OneSignalSDKNew.Debug.Utilities;

namespace OneSignalSDKNew.Android.Location {
namespace OneSignalSDK.Android.Location {
internal sealed class AndroidLocationManager : ILocationManager {
private readonly AndroidJavaObject _location;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

using UnityEngine;
using System.Threading.Tasks;
using OneSignalSDKNew.Notifications;
using OneSignalSDKNew.Notifications.Models;
using OneSignalSDKNew.Android.Utilities;
using OneSignalSDK.Notifications;
using OneSignalSDK.Notifications.Models;
using OneSignalSDK.Android.Utilities;
using System.Collections.Generic;

namespace OneSignalSDKNew.Android.Notifications {
namespace OneSignalSDK.Android.Notifications {
internal sealed class AndroidNotificationsManager : INotificationsManager {
private readonly AndroidJavaObject _notifications;

Expand All @@ -55,8 +55,7 @@ public async Task<bool> RequestPermissionAsync(bool fallbackToSettings) {
}

public void ClearAllNotifications() {
var continuation = new Continuation();
_notifications.Call<AndroidJavaObject>("clearAllNotifications", continuation.Proxy);
_notifications.Call("clearAllNotifications");
}

public void Initialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

using System;
using UnityEngine;
using OneSignalSDKNew.User.Models;
using OneSignalSDKNew.Android.Utilities;
using OneSignalSDK.User.Models;
using OneSignalSDK.Android.Utilities;

namespace OneSignalSDKNew.Android.User.Models {
namespace OneSignalSDK.Android.User.Models {
internal sealed class AndroidPushSubscription : IPushSubscription {
public event SubscriptionChangedDelegate Changed;

Expand Down
4 changes: 2 additions & 2 deletions com.onesignal.unity.android/Runtime/AndroidSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/

using UnityEngine;
using OneSignalSDKNew.Session;
using OneSignalSDK.Session;

namespace OneSignalSDKNew.Android.Session {
namespace OneSignalSDK.Android.Session {
internal sealed class AndroidSessionManager : ISessionManager {
private readonly AndroidJavaObject _session;

Expand Down
10 changes: 5 additions & 5 deletions com.onesignal.unity.android/Runtime/AndroidUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

using UnityEngine;
using System.Collections.Generic;
using OneSignalSDKNew.User;
using OneSignalSDKNew.User.Models;
using OneSignalSDKNew.Android.User.Models;
using OneSignalSDKNew.Android.Utilities;
using OneSignalSDK.User;
using OneSignalSDK.User.Models;
using OneSignalSDK.Android.User.Models;
using OneSignalSDK.Android.Utilities;

namespace OneSignalSDKNew.Android.User {
namespace OneSignalSDK.Android.User {
internal sealed class AndroidUserManager : IUserManager {
private readonly AndroidJavaObject _user;
private AndroidPushSubscription _pushSubscription;
Expand Down
37 changes: 21 additions & 16 deletions com.onesignal.unity.android/Runtime/OneSignalAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,30 @@
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using OneSignalSDKNew.Notifications;
using OneSignalSDKNew.InAppMessages;
using OneSignalSDKNew.Debug;
using OneSignalSDKNew.Debug.Utilities;
using OneSignalSDKNew.Location;
using OneSignalSDKNew.Session;
using OneSignalSDKNew.User;
using OneSignalSDKNew.Android.Notifications;
using OneSignalSDKNew.Android.InAppMessages;
using OneSignalSDKNew.Android.Debug;
using OneSignalSDKNew.Android.Location;
using OneSignalSDKNew.Android.Session;
using OneSignalSDKNew.Android.User;

namespace OneSignalSDKNew.Android { // TODO: Fix namespace to OneSignalSDK
using OneSignalSDK.Notifications;
using OneSignalSDK.InAppMessages;
using OneSignalSDK.Debug;
using OneSignalSDK.Debug.Utilities;
using OneSignalSDK.Location;
using OneSignalSDK.Session;
using OneSignalSDK.User;
using OneSignalSDK.Android.Notifications;
using OneSignalSDK.Android.InAppMessages;
using OneSignalSDK.Android.Debug;
using OneSignalSDK.Android.Location;
using OneSignalSDK.Android.Session;
using OneSignalSDK.Android.User;

namespace OneSignalSDK.Android {
public sealed partial class OneSignalAndroid : OneSignal {
private const string SDKPackage = "com.onesignal";
private const string SDKClassName = "OneSignal";
private const string QualifiedSDKClass = SDKPackage + "." + SDKClassName;

private readonly AndroidJavaClass _sdkClass = new AndroidJavaClass(QualifiedSDKClass);

private readonly AndroidJavaClass _sdkWrapperClass = new AndroidJavaClass(SDKPackage + ".common.OneSignalWrapper");

private static OneSignalAndroid _instance;

private AndroidUserManager _user;
Expand Down Expand Up @@ -112,6 +114,9 @@ public override void Initialize(string appId) {
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

_sdkWrapperClass.CallStatic("setSdkType", "unity");
//_sdkWrapperClass.CallStatic("setSdkVersion", "050000");

_sdkClass.CallStatic("initWithContext", activity, appId);

if (_inAppMessages == null) {
Expand Down Expand Up @@ -141,7 +146,7 @@ public override void Initialize(string appId) {
}

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

public override void Logout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#if UNITY_ANDROID && !UNITY_EDITOR
using UnityEngine;

namespace OneSignalSDKNew.Android {
namespace OneSignalSDK.Android {
/// <summary>
///
/// </summary>
Expand Down
Loading

0 comments on commit b9c675c

Please sign in to comment.