Skip to content

Commit

Permalink
demoapp/bump_applovin_plugin_8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AppLovin-Mobile-Engineering committed Oct 27, 2024
1 parent d77ad2b commit e0f5a3d
Show file tree
Hide file tree
Showing 37 changed files with 337 additions and 999 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.

4 changes: 2 additions & 2 deletions DemoApp/Assets/MaxSdk/AppLovin/Editor/Dependencies.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="com.applovin:applovin-sdk:13.0.0" />
<androidPackage spec="com.applovin:applovin-sdk:13.0.1" />
</androidPackages>
<iosPods>
<iosPod name="AppLovinSDK" version="13.0.0" />
<iosPod name="AppLovinSDK" version="13.0.1" />
</iosPods>
</dependencies>
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.

6 changes: 6 additions & 0 deletions DemoApp/Assets/MaxSdk/AppLovin/Plugins/iOS/MAUnityAdManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
extern "C" {
#endif

extern bool max_unity_should_disable_all_logs(void); // Forward declaration

// UnityAppController.mm
UIViewController* UnityGetGLViewController(void);
UIWindow* UnityGetMainWindow(void);
Expand Down Expand Up @@ -1544,6 +1546,8 @@ - (void)logInvalidAdFormat:(MAAdFormat *)adFormat

- (void)log:(NSString *)format, ...
{
if (max_unity_should_disable_all_logs()) return;

va_list valist;
va_start(valist, format);
NSString *message = [[NSString alloc] initWithFormat: format arguments: valist];
Expand All @@ -1554,6 +1558,8 @@ - (void)log:(NSString *)format, ...

+ (void)log:(NSString *)format, ...
{
if (max_unity_should_disable_all_logs()) return;

va_list valist;
va_start(valist, format);
NSString *message = [[NSString alloc] initWithFormat: format arguments: valist];
Expand Down
49 changes: 34 additions & 15 deletions DemoApp/Assets/MaxSdk/AppLovin/Plugins/iOS/MAUnityPlugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

#import "MAUnityAdManager.h"

#define VERSION @"8.0.0"
#define VERSION @"8.0.1"
#define NSSTRING(_X) ( (_X != NULL) ? [NSString stringWithCString: _X encoding: NSStringEncodingConversionAllowLossy].al_stringByTrimmingWhitespace : nil)

@interface NSString (ALUtils)
@property (nonatomic, copy, readonly) NSString *al_stringByTrimmingWhitespace;
@property (assign, readonly, getter=al_isValidString) BOOL al_validString;
- (BOOL)al_isEqualToStringIgnoringCase:(nullable NSString *)otherString;
@end

@interface ALSdkInitializationConfigurationBuilder (ALUtils)
Expand All @@ -35,11 +36,13 @@ - (void)setSdkKey:(NSString *)sdkKey;

static bool _isSdkInitialized = false;
static bool _initializeSdkCalled = false;
static bool _disableAllLogs = false;

// Helper method to create C string copy
static const char * cStringCopy(NSString *string);
// Helper method to log errors
void logUninitializedAccessError(const char *callingMethod);
void e(NSString *message);

ALSdk *getSdk()
{
Expand Down Expand Up @@ -72,6 +75,11 @@ - (void)setSdkKey:(NSString *)sdkKey;
return _initConfigurationBuilder;
}

bool max_unity_should_disable_all_logs()
{
return _disableAllLogs;
}

int getConsentStatusValue(NSNumber *consentStatus)
{
if ( consentStatus )
Expand Down Expand Up @@ -200,7 +208,7 @@ void _MaxShowMediationDebugger()
{
if ( !_initializeSdkCalled )
{
NSLog(@"[%@] Failed to show mediation debugger - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!", TAG);
e(@"Failed to show mediation debugger - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!");
return;
}

Expand All @@ -211,18 +219,13 @@ void _MaxShowCreativeDebugger()
{
if ( !_initializeSdkCalled )
{
NSLog(@"[%@] Failed to show creative debugger - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!", TAG);
e(@"Failed to show creative debugger - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!");
return;
}

[getSdk() showCreativeDebugger];
}

void _MaxShowConsentDialog()
{
NSLog(@"[%@] Failed to show consent dialog - Unavailable on iOS, please use the consent flow: https://developers.applovin.com/en/unity/overview/terms-and-privacy-policy-flow", TAG);
}


int _MaxConsentDialogState()
{
if ( !_isSdkInitialized ) return ALConsentDialogStateUnknown;
Expand All @@ -239,7 +242,7 @@ void _MaxSetSegmentCollection(const char *collectionJson)
{
if ( _initializeSdkCalled )
{
NSLog(@"[%@] Segment collection must be set before MAX SDK is initialized", TAG);
e(@"Segment collection must be set before MAX SDK is initialized");
return;
}

Expand Down Expand Up @@ -1066,7 +1069,7 @@ void _MaxSetTestDeviceAdvertisingIdentifiers(char **advertisingIdentifiers, int
{
if ( _initializeSdkCalled )
{
NSLog(@"[%@] Test device advertising IDs must be set before MAX SDK is initialized", TAG);
e(@"Test device advertising IDs must be set before MAX SDK is initialized");
return;
}

Expand All @@ -1083,7 +1086,7 @@ void _MaxSetExceptionHandlerEnabled(bool enabled)
{
if ( _initializeSdkCalled )
{
NSLog(@"[%@] Exception handler must be enabled/disabled before MAX SDK is initialized", TAG);
e(@"Exception handler must be enabled/disabled before MAX SDK is initialized");
return;
}

Expand All @@ -1095,12 +1098,19 @@ void _MaxSetExtraParameter(const char *key, const char *value)
NSString *stringKey = NSSTRING(key);
if ( ![stringKey al_isValidString] )
{
NSLog(@"[%@] Failed to set extra parameter for nil or empty key: %@", TAG, stringKey);
NSString *message = [NSString stringWithFormat:@"Failed to set extra parameter for nil or empty key: %@", stringKey];
e(message);
return;
}

NSString *stringValue = NSSTRING(value);
if ( [@"disable_all_logs" isEqualToString: stringKey] )
{
_disableAllLogs = [@"true" al_isEqualToStringIgnoringCase: stringValue];
}

ALSdkSettings *settings = getSdk().settings;
[settings setExtraParameterForKey: stringKey value: NSSTRING(value)];
[settings setExtraParameterForKey: stringKey value: stringValue];
}

int * _MaxGetSafeAreaInsets()
Expand Down Expand Up @@ -1139,7 +1149,16 @@ float _MaxGetAdaptiveBannerHeight(const float width)

void logUninitializedAccessError(const char *callingMethod)
{
NSLog(@"[%@] Failed to execute: %s - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!", TAG, callingMethod);
NSString *message = [NSString stringWithFormat:@"Failed to execute: %s - please ensure the AppLovin MAX Unity Plugin has been initialized by calling 'MaxSdk.InitializeSdk();'!", callingMethod];
e(message);
}

void e(NSString *message)
{
if (_disableAllLogs) return;

NSString *logMessage = [NSString stringWithFormat: @"[%@] %@", TAG, message];
NSLog(@"%@", logMessage);
}
}

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 @@ -84,7 +84,7 @@ private static void ShowPluginUpdateDialogIfNeeded(PluginData data)

// Check if the current and latest version are the same or if the publisher is on a newer version (on beta). If so, skip update.
var comparison = data.AppLovinMax.CurrentToLatestVersionComparisonResult;
if (comparison == Versions.VersionComparisonResult.Equal || comparison == Versions.VersionComparisonResult.Greater) return;
if (comparison == MaxSdkUtils.VersionComparisonResult.Equal || comparison == MaxSdkUtils.VersionComparisonResult.Greater) return;

// A new version of the plugin is available. Show a dialog to the publisher.
var option = EditorUtility.DisplayDialogComplex(
Expand Down Expand Up @@ -156,15 +156,15 @@ private static void ShowGoogleNetworkAdaptersUpdateDialogIfNeeded(Network[] netw

private static bool GoogleNetworkAdaptersCompatible(string googleVersion, string googleAdManagerVersion, string breakingVersion)
{
var googleResult = AppLovinIntegrationManagerUtils.CompareVersions(googleVersion, breakingVersion);
var googleAdManagerResult = AppLovinIntegrationManagerUtils.CompareVersions(googleAdManagerVersion, breakingVersion);
var googleResult = MaxSdkUtils.CompareVersions(googleVersion, breakingVersion);
var googleAdManagerResult = MaxSdkUtils.CompareVersions(googleAdManagerVersion, breakingVersion);

// If one is less than the breaking version and the other is not, they are not compatible.
if (googleResult == Versions.VersionComparisonResult.Lesser &&
googleAdManagerResult != Versions.VersionComparisonResult.Lesser) return false;
if (googleResult == MaxSdkUtils.VersionComparisonResult.Lesser &&
googleAdManagerResult != MaxSdkUtils.VersionComparisonResult.Lesser) return false;

if (googleAdManagerResult == Versions.VersionComparisonResult.Lesser &&
googleResult != Versions.VersionComparisonResult.Lesser) return false;
if (googleAdManagerResult == MaxSdkUtils.VersionComparisonResult.Lesser &&
googleResult != MaxSdkUtils.VersionComparisonResult.Lesser) return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,51 +87,43 @@ static AppLovinInitialize()
}
#endif

var pluginParentDir = AppLovinIntegrationManager.PluginParentDirectory;
var isPluginInPackageManager = AppLovinIntegrationManager.IsPluginInPackageManager;
var changesMade = AppLovinIntegrationManager.MovePluginFilesIfNeeded(pluginParentDir, isPluginInPackageManager);
if (isPluginInPackageManager)
if (!isPluginInPackageManager)
{
// If the plugin is not under the assets folder, delete the MaxSdk/Mediation folder in the plugin, so that the adapters are not imported at that location and imported to the default location.
var mediationDir = Path.Combine(pluginParentDir, "MaxSdk/Mediation");
if (Directory.Exists(mediationDir))
var changesMade = false;
foreach (var obsoleteFileExportPathToDelete in ObsoleteFileExportPathsToDelete)
{
FileUtil.DeleteFileOrDirectory(mediationDir);
FileUtil.DeleteFileOrDirectory(mediationDir + ".meta");
changesMade = true;
var pathToDelete = MaxSdkUtils.GetAssetPathForExportPath(obsoleteFileExportPathToDelete);
if (CheckExistence(pathToDelete))
{
MaxSdkLogger.UserDebug("Deleting obsolete file '" + pathToDelete + "' that is no longer needed.");
FileUtil.DeleteFileOrDirectory(pathToDelete);
changesMade = true;
}
}
}

foreach (var obsoleteFileExportPathToDelete in ObsoleteFileExportPathsToDelete)
{
var pathToDelete = MaxSdkUtils.GetAssetPathForExportPath(obsoleteFileExportPathToDelete);
if (CheckExistence(pathToDelete))
var pluginParentDir = AppLovinIntegrationManager.PluginParentDirectory;
// Check if any obsolete networks are installed
foreach (var obsoleteNetwork in ObsoleteNetworks)
{
MaxSdkLogger.UserDebug("Deleting obsolete file '" + pathToDelete + "' that are no longer needed.");
FileUtil.DeleteFileOrDirectory(pathToDelete);
changesMade = true;
var networkDir = Path.Combine(pluginParentDir, "MaxSdk/Mediation/" + obsoleteNetwork);
if (CheckExistence(networkDir))
{
MaxSdkLogger.UserDebug("Deleting obsolete network " + obsoleteNetwork + " from path " + networkDir + "...");
FileUtil.DeleteFileOrDirectory(networkDir);
FileUtil.DeleteFileOrDirectory(networkDir + ".meta");
changesMade = true;
}
}
}

// Check if any obsolete networks are installed
foreach (var obsoleteNetwork in ObsoleteNetworks)
{
var networkDir = Path.Combine(pluginParentDir, "MaxSdk/Mediation/" + obsoleteNetwork);
if (CheckExistence(networkDir))
// Refresh UI
if (changesMade)
{
MaxSdkLogger.UserDebug("Deleting obsolete network " + obsoleteNetwork + " from path " + networkDir + "...");
FileUtil.DeleteFileOrDirectory(networkDir);
changesMade = true;
AssetDatabase.Refresh();
MaxSdkLogger.UserDebug("Obsolete networks and files removed.");
}
}

// Refresh UI
if (changesMade)
{
AssetDatabase.Refresh();
MaxSdkLogger.UserDebug("AppLovin MAX Migration completed");
}

AppLovinAutoUpdater.Update();
}

Expand Down
Loading

0 comments on commit e0f5a3d

Please sign in to comment.