From aa60e1b6936357306c3c84ac2a79e91d4e6de350 Mon Sep 17 00:00:00 2001 From: Leo Forner Date: Fri, 19 Aug 2022 13:47:59 +0200 Subject: [PATCH] Updated with crossdk-ios 3.2.2 --- .gitignore | 4 ++++ Assets/CrossDK/CrossDKConverter.cs | 24 ++++++++++++------- Assets/CrossDK/CrossDKSingleton.cs | 11 +++++++-- Assets/CrossDK/Editor/CrossDKDependencies.xml | 2 +- Assets/Plugins/iOS/CrossDKBridge.m | 9 +++++++ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 8af868e..a639834 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ /[Bb]uilds/ /[Ll]ogs/ /[Mm]emoryCaptures/ +/[Pp]ackages/ +/[Pp]rojectSettings/ # Asset meta data should only be ignored when the corresponding asset is also ignored !/[Aa]ssets/**/*.meta @@ -21,6 +23,7 @@ # Visual Studio cache directory .vs/ +.vsconfig # Gradle cache directory .gradle/ @@ -47,6 +50,7 @@ ExportedObj/ *.pidb.meta *.pdb.meta *.mdb.meta +*.meta # Unity3D generated file on crash reports sysinfo.txt diff --git a/Assets/CrossDK/CrossDKConverter.cs b/Assets/CrossDK/CrossDKConverter.cs index 4763b9c..5ee4d2f 100644 --- a/Assets/CrossDK/CrossDKConverter.cs +++ b/Assets/CrossDK/CrossDKConverter.cs @@ -1,3 +1,4 @@ +using System; using System.Runtime.InteropServices; using UnityEngine; @@ -11,6 +12,9 @@ public class CrossDKConverter [DllImport("__Internal")] private static extern void crossDKConfigWithAppId(string appId, string apiKey, string userId); + [DllImport("__Internal")] + private static extern void setDeviceId(string deviceId); + [DllImport("__Internal")] private static extern void dismissOverlay(); @@ -21,14 +25,6 @@ public class CrossDKConverter private const string CONFIG = "config"; private const string DISMISS = "dismissOverlay"; private const string DISPLAY = "displayOverlay"; - //[DllImport("CrossDK")] - //private static extern void crossDKConfigWithAppId(string appId, string apiKey, string userId); - - //[DllImport("CrossDK")] - //private static extern void dismissOverlay(); - - //[DllImport("CrossDK")] - //private static extern void displayOverlayWithFormat(int format, int position, bool withCloseButton, bool isRewarded); #endif /* Public interface for use inside C# code */ @@ -52,6 +48,18 @@ public static void CrossDKConfigWithAppId(string appId = "", string apiKey = "", #endif } + public static void SetDeviceId(string deviceId) + { +#if UNITY_EDITOR + Debug.Log("SetDeviceId called in editor"); +#elif UNITY_IOS + setDeviceId(deviceId); +#endif +#if UNITY_ANDROID + // Not available yet +#endif + } + public static void DismissOverlay() { #if UNITY_EDITOR diff --git a/Assets/CrossDK/CrossDKSingleton.cs b/Assets/CrossDK/CrossDKSingleton.cs index bff64f7..bf3b235 100644 --- a/Assets/CrossDK/CrossDKSingleton.cs +++ b/Assets/CrossDK/CrossDKSingleton.cs @@ -1,4 +1,6 @@ +using System; using UnityEngine; +using UnityEngine.Networking.Types; namespace CrossDK { @@ -23,7 +25,7 @@ public class CrossDKSingleton : MonoBehaviour [SerializeField] private bool _autoCallConfig; [SerializeField] private string _appId; [SerializeField] private string _apiKey; - [SerializeField] private string _idfv; + [SerializeField] private string _userId; private void Awake() { @@ -37,7 +39,7 @@ private void Awake() if (_autoCallConfig) { - Config(_appId, _apiKey, _idfv); + Config(_appId, _apiKey, _userId); } } @@ -48,6 +50,11 @@ public static void Config(string appId = "", string apiKey = "", string userId = CrossDKConverter.CrossDKConfigWithAppId(appId, apiKey, userId); } + public static void SetDeviceId(string deviceId) + { + CrossDKConverter.SetDeviceId(deviceId); + } + public static void DismissOverlay() { CrossDKConverter.DismissOverlay(); diff --git a/Assets/CrossDK/Editor/CrossDKDependencies.xml b/Assets/CrossDK/Editor/CrossDKDependencies.xml index 562a9fb..1903899 100644 --- a/Assets/CrossDK/Editor/CrossDKDependencies.xml +++ b/Assets/CrossDK/Editor/CrossDKDependencies.xml @@ -34,7 +34,7 @@ * "subspecs" (optional) Subspecs to include for the pod. --> - + https://github.com/CocoaPods/Specs diff --git a/Assets/Plugins/iOS/CrossDKBridge.m b/Assets/Plugins/iOS/CrossDKBridge.m index e6b4e3e..6c06832 100644 --- a/Assets/Plugins/iOS/CrossDKBridge.m +++ b/Assets/Plugins/iOS/CrossDKBridge.m @@ -61,6 +61,15 @@ void crossDKConfigWithAppId(const char *appId, const char *apiKey, const char *u ]; } +/// Set the device ID. +/// +/// - Parameters: +/// - deviceId: current device ID +void setDeviceId(const char* deviceId) { + NSString *nsDeviceId = makeNSString(deviceId); + CrossDKConfig.shared.deviceId = nsDeviceId; +} + /// Displays an Overlay view. /// /// - Parameters: