Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from Adikteev/release/4.0.0
Browse files Browse the repository at this point in the history
release:v4.0.0
  • Loading branch information
dhakertrimech authored Feb 28, 2023
2 parents 3870acb + f736634 commit 1bd473a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Assets/CrossDK/CrossDKConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion Assets/CrossDK/CrossDKSingleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ internal void OverlayUnavailableWithError(string message)
{
overlayUnavailableWithErrorDelegate?.Invoke(message);
}

#endregion
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/CrossDK/Editor/CrossDKDependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* "subspecs" (optional)
Subspecs to include for the pod.
-->
<iosPod name="CrossDK" version="3.3.2" addToAllTargets="true">
<iosPod name="CrossDK" version="4.0.1" addToAllTargets="true">
<sources>
<source>https://github.com/CocoaPods/Specs</source>
</sources>
Expand Down
1 change: 1 addition & 0 deletions Assets/CrossDK/Editor/IOSPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 59 additions & 4 deletions Assets/Plugins/iOS/CrossDKBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ @interface CrossDKBridge ()

@implementation CrossDKBridge


NSString* makeNSString (const char* string) {
if (string) {
return [NSString stringWithUTF8String: string];
Expand All @@ -39,7 +40,6 @@ @implementation CrossDKBridge
}

void unitySendMessage(const char *method, NSString *message) {
NSLog(@"%@", message);
UnitySendMessage("CrossDK", method, makeCString(message));
}

Expand All @@ -61,6 +61,9 @@ void crossDKConfigWithAppId(const char *appId, const char *apiKey, const char *u
];
}




/// Set the device ID.
///
/// - Parameters:
Expand All @@ -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];
Expand All @@ -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");
}
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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


0 comments on commit 1bd473a

Please sign in to comment.