diff --git a/Assets/CrossDK/CrossDKConverter.cs b/Assets/CrossDK/CrossDKConverter.cs index 870c08d..6432806 100644 --- a/Assets/CrossDK/CrossDKConverter.cs +++ b/Assets/CrossDK/CrossDKConverter.cs @@ -20,6 +20,9 @@ public class CrossDKConverter [DllImport("__Internal")] private static extern void displayOverlayWithFormat(int format, int position, bool withCloseButton, bool isRewarded); + + [DllImport("__Internal")] + private static extern void loadOverlayWithFormat(int format, int position, bool withCloseButton, bool isRewarded); #elif UNITY_ANDROID private static AndroidJavaObject crossDKWrapper; private const string CONFIG = "config"; @@ -79,7 +82,7 @@ public static void LoadOverlayWithFormat(OverlayFormat format, OverlayPosition p #if UNITY_EDITOR Debug.Log("DisplayOverlayWithFormat called in editor"); #elif UNITY_IOS - displayOverlayWithFormat((int)format, (int)position, withCloseButton, isRewarded); + loadOverlayWithFormat((int)format, (int)position, withCloseButton, isRewarded); #endif #if UNITY_ANDROID object[] parameters = new object[4]; diff --git a/Assets/CrossDK/CrossDKSingleton.cs b/Assets/CrossDK/CrossDKSingleton.cs index a223916..a8a0da1 100644 --- a/Assets/CrossDK/CrossDKSingleton.cs +++ b/Assets/CrossDK/CrossDKSingleton.cs @@ -151,7 +151,7 @@ internal void OverlayUnavailableWithError(string message) { overlayUnavailableWithErrorDelegate?.Invoke(message); } - + #endregion } diff --git a/Assets/CrossDK/Editor/CrossDKDependencies.xml b/Assets/CrossDK/Editor/CrossDKDependencies.xml index 84db41e..4a36469 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/CrossDK/Editor/IOSPostProcess.cs b/Assets/CrossDK/Editor/IOSPostProcess.cs index 027bae8..7cdc670 100644 --- a/Assets/CrossDK/Editor/IOSPostProcess.cs +++ b/Assets/CrossDK/Editor/IOSPostProcess.cs @@ -18,6 +18,7 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath) project.SetBuildProperty(project.ProjectGuid(), "CLANG_ENABLE_MODULES", "YES"); project.SetBuildProperty(project.ProjectGuid(), "CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER", "YES"); project.SetBuildProperty(project.ProjectGuid(), "ALWAYS_SEARCH_USER_PATHS", "NO"); + project.SetBuildProperty(project.ProjectGuid(), "ENABLE_BITCODE", "NO"); project.WriteToFile(pbxProjectPath); #elif UNITY_ANDROID diff --git a/Assets/Plugins/iOS/CrossDKBridge.m b/Assets/Plugins/iOS/CrossDKBridge.m index 6c06832..9e0a451 100644 --- a/Assets/Plugins/iOS/CrossDKBridge.m +++ b/Assets/Plugins/iOS/CrossDKBridge.m @@ -19,6 +19,7 @@ @interface CrossDKBridge () @implementation CrossDKBridge + NSString* makeNSString (const char* string) { if (string) { return [NSString stringWithUTF8String: string]; @@ -39,7 +40,6 @@ @implementation CrossDKBridge } void unitySendMessage(const char *method, NSString *message) { - NSLog(@"%@", message); UnitySendMessage("CrossDK", method, makeCString(message)); } @@ -61,6 +61,9 @@ void crossDKConfigWithAppId(const char *appId, const char *apiKey, const char *u ]; } + + + /// Set the device ID. /// /// - Parameters: @@ -77,7 +80,32 @@ void setDeviceId(const char* deviceId) { /// - position: banner and mid_size overlay position /// - withCloseButton: mid_size and interstitial overlay close button /// - isRewarded: provides some kind of value for the user (interstitial format only) - - (void) displayOverlayWithFormat:(OverlayFormat)isFormat position:(OverlayPosition)isPosition withCloseButton:(BOOL*)isWithCloseButton isRewarded:(BOOL*)isIsRewarded { +- (void) displayOverlayWithFormat:(OverlayFormat)isFormat position:(OverlayPosition)isPosition withCloseButton:(BOOL*)isWithCloseButton isRewarded:(BOOL*)isIsRewarded { + + _crossDKOverlay = [[CrossDKOverlay alloc] init]; + UIWindow *window = [[UIApplication sharedApplication] keyWindow]; + self.crossDKOverlayDelegate = [[CrossDKOverlayDelegate alloc] initWithParentBridge: self]; + self.crossDKOverlay.delegate = self.crossDKOverlayDelegate; + if (window != nil) { + [ + self.crossDKOverlay + displayWithWindow:window + format:isFormat + position:isPosition + withCloseButton:isWithCloseButton + isRewarded:isIsRewarded + ]; + } +} + + /// Load an Overlay view. +/// +/// - Parameters: +/// - format: banner, mid_size, interstitial overlay +/// - position: banner and mid_size overlay position +/// - withCloseButton: mid_size and interstitial overlay close button +/// - isRewarded: provides some kind of value for the user (interstitial format only) + - (void) loadOverlayWithFormat:(OverlayFormat)isFormat position:(OverlayPosition)isPosition withCloseButton:(BOOL*)isWithCloseButton isRewarded:(BOOL*)isIsRewarded { _crossDKOverlay = [[CrossDKOverlay alloc] init]; UIWindow *window = [[UIApplication sharedApplication] keyWindow]; self.crossDKOverlayDelegate = [[CrossDKOverlayDelegate alloc] initWithParentBridge: self]; @@ -86,12 +114,13 @@ - (void) displayOverlayWithFormat:(OverlayFormat)isFormat position:(OverlayPosit if (window != nil) { [ self.crossDKOverlay - displayWithWindow:window + loadWithWindow:window format:isFormat position:isPosition withCloseButton:isWithCloseButton isRewarded:isIsRewarded ]; + unitySendMessage("OverlayWillStartPreload", @"Overlay will start preload"); } } @@ -129,10 +158,23 @@ void dismissOverlay() { void displayOverlayWithFormat(OverlayFormat format, OverlayPosition position, BOOL* withCloseButton, BOOL* isRewarded) { if (delegateObject == nil) delegateObject = [[CrossDKBridge alloc] init]; - [delegateObject displayOverlayWithFormat:format position:position withCloseButton:withCloseButton isRewarded:isRewarded]; } + /// Preload feature before display. +/// +/// - Parameters: +/// - format: banner, mid_size, interstitial overlay +/// - position: banner and mid_size overlay position +/// - withCloseButton: mid_size and interstitial overlay close button +/// - isRewarded: provides some kind of value for the user (interstitial format only) + void loadOverlayWithFormat(OverlayFormat format, OverlayPosition position, BOOL* withCloseButton, BOOL* isRewarded) { + if (delegateObject == nil) + delegateObject = [[CrossDKBridge alloc] init]; + + [delegateObject loadOverlayWithFormat:format position:position withCloseButton:withCloseButton isRewarded:isRewarded]; + } + @implementation CrossDKOverlayDelegate -(instancetype)initWithParentBridge:(CrossDKBridge *)parentBridge { @@ -200,4 +242,17 @@ -(void)overlayUnavailableWithError:(enum OverlayError)error { } } +-(void)overlayDidPreload { + unitySendMessage("OverlayDidFinishPreload", @"Overlay did finish preload"); +} + +-(void)overlayPreloadFailure { + unitySendMessage("OverlayDidFailToLoadWithError", @"Overlay did fail to load with error"); +} + +-(void)overlayPreloadExpired { + unitySendMessage("OverlayPreloadExpired", @"Overlay preload expired"); +} @end + +