Skip to content

Commit

Permalink
demoapp/bump_applovin_plugin_6.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Apr 11, 2024
1 parent 604c283 commit 07378ee
Show file tree
Hide file tree
Showing 20 changed files with 193 additions and 166 deletions.
2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/AppLovin.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/AppLovin/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/AppLovin/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/AppLovin/Plugins/Android.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/AppLovin/Plugins/iOS.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 49 additions & 43 deletions DemoApp/Assets/MaxSdk/AppLovin/Plugins/iOS/MAUnityAdManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#import "MAUnityAdManager.h"

#define VERSION @"6.4.2"
#define VERSION @"6.4.3"

#define KEY_WINDOW [UIApplication sharedApplication].keyWindow
#define DEVICE_SPECIFIC_ADVIEW_AD_FORMAT ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) ? MAAdFormat.leader : MAAdFormat.banner
Expand Down Expand Up @@ -655,53 +655,54 @@ - (NSString *)adValueForAdUnitIdentifier:(nullable NSString *)adUnitIdentifier w

- (void)didLoadAd:(MAAd *)ad
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *name;
MAAdFormat *adFormat = ad.format;
if ( [adFormat isAdViewAd] )
{
MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: ad.adUnitIdentifier adFormat: adFormat];
// An ad is now being shown, enable user interaction.
adView.userInteractionEnabled = YES;

if ( MAAdFormat.mrec == adFormat )
{
name = @"OnMRecAdLoadedEvent";
}
else
{
name = @"OnBannerAdLoadedEvent";
}
[self positionAdViewForAd: ad];

// Do not auto-refresh by default if the ad view is not showing yet (e.g. first load during app launch and publisher does not automatically show banner upon load success)
// We will resume auto-refresh in -[MAUnityAdManager showBannerWithAdUnitIdentifier:].
if ( adView && [adView isHidden] )
{
[adView stopAutoRefresh];
}
}
else if ( MAAdFormat.interstitial == adFormat )
{
name = @"OnInterstitialLoadedEvent";
}
else if ( MAAdFormat.appOpen == adFormat )
{
name = @"OnAppOpenAdLoadedEvent";
}
else if ( MAAdFormat.rewarded == adFormat )
NSString *name;
MAAdFormat *adFormat = ad.format;
if ( [adFormat isAdViewAd] )
{
MAAdView *adView = [self retrieveAdViewForAdUnitIdentifier: ad.adUnitIdentifier adFormat: adFormat];
// An ad is now being shown, enable user interaction.
adView.userInteractionEnabled = YES;

if ( MAAdFormat.mrec == adFormat )
{
name = @"OnRewardedAdLoadedEvent";
name = @"OnMRecAdLoadedEvent";
}
else if ( MAAdFormat.rewardedInterstitial == adFormat )
else
{
name = @"OnRewardedInterstitialAdLoadedEvent";
name = @"OnBannerAdLoadedEvent";
}
else
[self positionAdViewForAd: ad];

// Do not auto-refresh by default if the ad view is not showing yet (e.g. first load during app launch and publisher does not automatically show banner upon load success)
// We will resume auto-refresh in -[MAUnityAdManager showBannerWithAdUnitIdentifier:].
if ( adView && [adView isHidden] )
{
[self logInvalidAdFormat: adFormat];
return;
[adView stopAutoRefresh];
}
}
else if ( MAAdFormat.interstitial == adFormat )
{
name = @"OnInterstitialLoadedEvent";
}
else if ( MAAdFormat.appOpen == adFormat )
{
name = @"OnAppOpenAdLoadedEvent";
}
else if ( MAAdFormat.rewarded == adFormat )
{
name = @"OnRewardedAdLoadedEvent";
}
else if ( MAAdFormat.rewardedInterstitial == adFormat )
{
name = @"OnRewardedInterstitialAdLoadedEvent";
}
else
{
[self logInvalidAdFormat: adFormat];
return;
}

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

@synchronized ( self.adInfoDictLock )
{
Expand Down Expand Up @@ -776,6 +777,7 @@ - (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErro
- (void)didClickAd:(MAAd *)ad
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

NSString *name;
MAAdFormat *adFormat = ad.format;
if ( MAAdFormat.banner == adFormat || MAAdFormat.leader == adFormat )
Expand Down Expand Up @@ -852,6 +854,7 @@ - (void)didDisplayAd:(MAAd *)ad
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

// BMLs do not support [DISPLAY] events in Unity
MAAdFormat *adFormat = ad.format;
if ( ![adFormat isFullscreenAd] ) return;
Expand Down Expand Up @@ -996,6 +999,7 @@ - (void)didCompleteRewardedVideoForAd:(MAAd *)ad
- (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

MAAdFormat *adFormat = ad.format;
if ( adFormat != MAAdFormat.rewarded && adFormat != MAAdFormat.rewardedInterstitial )
{
Expand All @@ -1020,6 +1024,7 @@ - (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
- (void)didPayRevenueForAd:(MAAd *)ad
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

NSString *name;
MAAdFormat *adFormat = ad.format;
if ( MAAdFormat.banner == adFormat || MAAdFormat.leader == adFormat )
Expand Down Expand Up @@ -1061,6 +1066,7 @@ - (void)didPayRevenueForAd:(MAAd *)ad
- (void)didGenerateCreativeIdentifier:(NSString *)creativeIdentifier forAd:(MAAd *)ad
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

NSString *name;
MAAdFormat *adFormat = ad.format;
if ( MAAdFormat.banner == adFormat || MAAdFormat.leader == adFormat )
Expand Down Expand Up @@ -1707,7 +1713,7 @@ - (void)positionAdViewForAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:
// All positions have constant height
NSMutableArray<NSLayoutConstraint *> *constraints = [NSMutableArray arrayWithObject: [adView.heightAnchor constraintEqualToConstant: adViewSize.height]];

UILayoutGuide *layoutGuide = KEY_WINDOW.safeAreaLayoutGuide;
UILayoutGuide *layoutGuide = superview.safeAreaLayoutGuide;

if ( [adViewPosition isEqual: @"top_center"] || [adViewPosition isEqual: @"bottom_center"] )
{
Expand Down
2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/Resources/Images.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DemoApp/Assets/MaxSdk/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,37 @@ public static void ShowBuildFailureDialog(string message)
/// Checks whether or not an adapter with the given version or newer exists.
/// </summary>
/// <param name="adapterName">The name of the network (the root adapter folder name in "MaxSdk/Mediation/" folder.</param>
/// <param name="version">The min adapter version to check for. Can be <c>null</c> if we want to check for any version.</param>
/// <param name="iosVersion">The min adapter version to check for. Can be <c>null</c> if we want to check for any version.</param>
/// <returns><c>true</c> if an adapter with the min version is installed.</returns>
public static bool IsAdapterInstalled(string adapterName, string version = null)
public static bool IsAdapterInstalled(string adapterName, string iosVersion = null) // TODO: Add Android version check.
{
var dependencyFilePath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Mediation/" + adapterName + "/Editor/Dependencies.xml");
if (!File.Exists(dependencyFilePath)) return false;

// If version is null, we just need the adapter installed. We don't have to check for a specific version.
if (version == null) return true;
if (iosVersion == null) return true;

var currentVersion = AppLovinIntegrationManager.GetCurrentVersions(dependencyFilePath);
var iosVersionComparison = MaxSdkUtils.CompareVersions(currentVersion.Ios, version);
return iosVersionComparison != MaxSdkUtils.VersionComparisonResult.Lesser;
var currentVersion = GetCurrentVersions(dependencyFilePath);
var iosVersionComparison = MaxSdkUtils.CompareVersions(currentVersion.Ios, iosVersion);
return iosVersionComparison != VersionComparisonResult.Lesser;
}

/// <summary>
/// Checks whether or not an adapter older than the given version exists.
///
/// TODO: Consolidate this method with <see cref="IsAdapterInstalled"/> and return a state enum.
/// </summary>
/// <param name="adapterName">The name of the network (the root adapter folder name in "MaxSdk/Mediation/" folder.</param>
/// <param name="iosVersion">The adapter version to check for.</param>
/// <returns><c>true</c> if an adapter older than the provided version is installed.</returns>
public static bool IsAdapterOlderThanMinVersionInstalled(string adapterName, string iosVersion) // TODO: Add Android version check.
{
var dependencyFilePath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Mediation/" + adapterName + "/Editor/Dependencies.xml");
if (!File.Exists(dependencyFilePath)) return false;

var currentVersion = GetCurrentVersions(dependencyFilePath);
var iosVersionComparison = MaxSdkUtils.CompareVersions(currentVersion.Ios, iosVersion);
return iosVersionComparison == VersionComparisonResult.Lesser;
}

#region Utility Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ public class AppLovinPostProcessiOS
{
private const string OutputFileName = "AppLovinQualityServiceSetup.rb";

#if !UNITY_2019_3_OR_NEWER
#if UNITY_2019_3_OR_NEWER
private const string TargetUnityIphonePodfileLine = "target 'Unity-iPhone' do";
private const string UseFrameworksPodfileLine = "use_frameworks!";
private const string UseFrameworksDynamicPodfileLine = "use_frameworks! :linkage => :dynamic";
private const string UseFrameworksStaticPodfileLine = "use_frameworks! :linkage => :static";
#else
private const string UnityMainTargetName = "Unity-iPhone";
#endif
private const string TargetUnityIphonePodfileLine = "target 'Unity-iPhone' do";
private const string LegacyResourcesDirectoryName = "Resources";
private const string AppLovinMaxResourcesDirectoryName = "AppLovinMAXResources";
private const string AppLovinAdvertisingAttributionEndpoint = "https://postbacks-app.com";
Expand All @@ -50,26 +54,45 @@ public class AppLovinPostProcessiOS
private const string KeyConsentFlowPrivacyPolicy = "ConsentFlowPrivacyPolicy";
private const string KeyConsentFlowDebugUserGeography = "ConsentFlowDebugUserGeography";

private static readonly List<string> DynamicLibrariesToEmbed = new List<string>
private static List<string> DynamicLibrariesToEmbed
{
"AppLovinSDK.xcframework",
"DTBiOSSDK.xcframework",
"FBAEMKit.xcframework",
"FBSDKCoreKit_Basics.xcframework",
"FBSDKCoreKit.xcframework",
"FBSDKGamingServicesKit.xcframework",
"FBSDKLoginKit.xcframework",
"FBSDKShareKit.xcframework",
"HyprMX.xcframework",
"LinkedinAudienceNetwork.xcframework",
"IASDKCore.xcframework",
"Maio.xcframework",
"MobileFuseSDK.xcframework",
"OMSDK_Appodeal.xcframework",
"OMSDK_Ogury.xcframework",
"OMSDK_Pubnativenet.xcframework",
"OMSDK_Smaato.xcframework"
};
get
{
var dynamicLibrariesToEmbed = new List<string>
{
"AppLovinSDK.xcframework",
"DTBiOSSDK.xcframework",
"FBAEMKit.xcframework",
"FBSDKCoreKit_Basics.xcframework",
"FBSDKCoreKit.xcframework",
"FBSDKGamingServicesKit.xcframework",
"FBSDKLoginKit.xcframework",
"FBSDKShareKit.xcframework",
"HyprMX.xcframework",
"Maio.xcframework",
"MobileFuseSDK.xcframework",
"MolocoSDK.xcframework",
"OMSDK_Appodeal.xcframework",
"OMSDK_Ogury.xcframework",
"OMSDK_Pubnativenet.xcframework",
"OMSDK_Smaato.xcframework"
};

// LinkedIn Audience Network SDK is distributed as a static library starting version 1.2.0
if (AppLovinIntegrationManager.IsAdapterOlderThanMinVersionInstalled("LinkedIn", "1.2.0.0"))
{
dynamicLibrariesToEmbed.Add("LinkedinAudienceNetwork.xcframework");
}

// Fyber/IA SDK is distributed as a static library starting version 8.2.7
if (AppLovinIntegrationManager.IsAdapterOlderThanMinVersionInstalled("Fyber", "8.2.7.0"))
{
dynamicLibrariesToEmbed.Add("IASDKCore.xcframework");
}

return dynamicLibrariesToEmbed;
}
}

private static string PluginMediationDirectory
{
Expand Down Expand Up @@ -214,8 +237,7 @@ private static void EmbedDynamicLibrariesIfNeeded(string buildPath, PBXProject p
if (dynamicLibraryPathsPresentInProject.Count <= 0) return;

#if UNITY_2019_3_OR_NEWER
// Embed framework only if the podfile does not contain target `Unity-iPhone`.
if (!ContainsUnityIphoneTargetInPodfile(buildPath))
if (ShouldEmbedDynamicLibraries(buildPath))
{
foreach (var dynamicLibraryPath in dynamicLibraryPathsPresentInProject)
{
Expand Down Expand Up @@ -651,13 +673,36 @@ private static SkAdNetworkData GetSkAdNetworkData()
}

#if UNITY_2019_3_OR_NEWER
private static bool ContainsUnityIphoneTargetInPodfile(string buildPath)
/// <summary>
/// |-----------------------------------------------------------------------------------------------------------------------------------------------------|
/// | embed | use_frameworks! (:linkage => :dynamic) | use_frameworks! :linkage => :static | `use_frameworks!` line not present |
/// |---------------------------|------------------------------------------|---------------------------------------|--------------------------------------|
/// | Unity-iPhone present | Do not embed dynamic libraries | Embed dynamic libraries | Do not embed dynamic libraries |
/// | Unity-iPhone not present | Embed dynamic libraries | Embed dynamic libraries | Embed dynamic libraries |
/// |-----------------------------------------------------------------------------------------------------------------------------------------------------|
/// </summary>
/// <param name="buildPath">An iOS build path</param>
/// <returns>Whether or not the dynamic libraries should be embedded.</returns>
private static bool ShouldEmbedDynamicLibraries(string buildPath)
{
var podfilePath = Path.Combine(buildPath, "Podfile");
if (!File.Exists(podfilePath)) return false;

// If the Podfile doesn't have a `Unity-iPhone` target, we should embed the dynamic libraries.
var lines = File.ReadAllLines(podfilePath);
return lines.Any(line => line.Contains(TargetUnityIphonePodfileLine));
var containsUnityIphoneTarget = lines.Any(line => line.Contains(TargetUnityIphonePodfileLine));
if (!containsUnityIphoneTarget) return true;

// If the Podfile does not have a `use_frameworks! :linkage => static` line, we should not embed the dynamic libraries.
var useFrameworksStaticLineIndex = Array.FindIndex(lines, line => line.Contains(UseFrameworksStaticPodfileLine));
if (useFrameworksStaticLineIndex == -1) return false;

// If more than one of the `use_frameworks!` lines are present, CocoaPods will use the last one.
var useFrameworksLineIndex = Array.FindIndex(lines, line => line.Trim() == UseFrameworksPodfileLine); // Check for exact line to avoid matching `use_frameworks! :linkage => static/dynamic`
var useFrameworksDynamicLineIndex = Array.FindIndex(lines, line => line.Contains(UseFrameworksDynamicPodfileLine));

// Check if `use_frameworks! :linkage => :static` is the last line of the three. If it is, we should embed the dynamic libraries.
return useFrameworksLineIndex < useFrameworksStaticLineIndex && useFrameworksDynamicLineIndex < useFrameworksStaticLineIndex;
}
#endif
}
Expand Down
Loading

0 comments on commit 07378ee

Please sign in to comment.