Skip to main content

Unity Initialization Guide

If Unity Mediation is used, the ad loading time can be reduced by pre-initializing the Unity SDK.

pod 'GFPSDK/MediationUnity'
danger

To initialize the Unity SDK, Unity initialization must be called before the GFP SDK initialization.

Add unity module

If GFPSDK/MediationUnity is listed in the Podfile, the UnityAds module with MediationUnity and dependency can be imported.

Import Unity modules to use the Unity SDK.

@import UnityAds;

Initialize

An example of Unity initialization is given below. When calling the API initialization, enablePerPlacementLoad must always be called with the setting YES.

@import UnityAds;

@interface UnityInitSample : NSObject <UnityAdsInitializationDelegate>

@end

@implementation UnityInitSample

- (void)initialize {
[UnityAds initialize:@"YourGameId" testMode:NO enablePerPlacementLoad:YES initializationDelegate:self];
}

//MARK: - UnityAdsInitializationDelegate

- (void)initializationComplete {
NSLog(@"[UnityInitSample] initializationComplete");
}

- (void)initializationFailed:(UnityAdsInitializationError)error withMessage:(NSString *)message {
NSLog(@"[UnityInitSample] initializationFailed: %d withMessage: %@", error, message);
}

@end