Содержание
Unity Ads SDK 2.0 - iOS API Reference
This is the public iOS API for Unity Ads SDK 2.0.
Contents
- UnityAds Class
- Enumerations
- Static Methods
- UnityAdsDelegate Protocol
- Callback Methods
UnityAds Class
Enumerations
The following enumerations are available as part of the UnityAds
class.
Static Methods
getDebugMode
(BOOL)getDebugMode;
Returns true
if Debug Mode is enabled.
getDelegate
(id<UnityAdsDelegate>)getDelegate;
Returns the current assigned Unity Ads delegate.
See UnityAdsDelegate.
getPlacementState
(UnityAdsPlacementState)getPlacementState;
(UnityAdsPlacementState)getPlacementState:(NSString *)placementId;
Returns the state of the specified ad placement ID. If a placement is not specified, the default ad placement will be used instead.
Parameter | Description |
---|---|
placementId |
The ad placement identifier. This can be found listed under the iOS platform of your project in the Unity Ads dashboard. |
getVersion
(NSString *)getVersion;
Returns the Unity Ads SDK version as a string.
initialize
(void)initialize:(NSString *)gameId delegate:(nullable id<UnityAdsDelegate>)delegate;
(void)initialize:(NSString *)gameId delegate:(nullable id<UnityAdsDelegate>)delegate testMode:(BOOL)testMode;
Initializes the Unity Ads SDK using the specified game ID.
Parameter | Description |
---|---|
gameId |
The platform specific game identifier. This can be found listed under your project in the Unity Ads dashboard. |
delegate |
The delegate class that implements UnityAdsDelegate . |
testMode |
Enables Test Mode when set to true . Test Mode defaults to being disabled when a value is not specified. While Test Mode is enabled, only test ads will be shown. Test ads do not generate any stats or revenue. |
isInitialized
(BOOL)isInitialized;
Returns true
if the Unity Ads SDK is initialized.
isReady
(BOOL)isReady;
(BOOL)isReady:(NSString *)placementId;
Returns true
if the specified ad placement is ready to show an ad campaign. If a placement is not specified, the default ad placement will be used instead.
Parameter | Description |
---|---|
placementId |
The ad placement identifier. This can be found listed under the iOS platform of your project in the Unity Ads dashboard. |
isSupported
(BOOL)isSupported;
Returns true
if Unity Ads is supported by the current device. Call this method before attempting to initialize Unity Ads.
setDebugMode
(void)setDebugMode:(BOOL)enableDebugMode;
Parameter | Description |
---|---|
enableDebugMode |
Logs are verbose when set to true , and minimal when false . |
setDelegate
(void)setDelegate:(id<UnityAdsDelegate>)delegate;
Parameter | Description |
---|---|
delegate |
The listener class that implements IUnityAdsListener. |
show
(void)show:(UIViewController *)viewController;
(void)show:(UIViewController *)viewController placementId:(NSString *)placementId;`
Shows an ad campaign using the specified ad placement. If no placement is specified, the default placement is used instead.
After the ad is shown, the method unityAdsDidFinish will be called when the ad placement is closed. This callback method can be used to reward players for opting-in to watch video ads.
Parameter | Description |
---|---|
viewController |
The current view controller used to call this method. |
placementId |
The ad placement identifier. This can be found listed under the Android platform of your project in the Unity Ads dashboard. |
UnityAdsDelegate Protocol
Callback Methods
unityAdsDidError
(void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message;
In addition to error logs, this method is called when an error occurs with Unity Ads. This method can be used to assist in debugging efforts, as well as for collect statistics on various failure scenarios.
Parameter | Description |
---|---|
error |
The Unity Ads error that occurred. See UnityAdsError . |
message |
A description of the error that occurred. |
unityAdsDidFinish
(void)unityAdsDidFinish:(NSString *)placementId withFinishState:(UnityAdsFinishState)state;
This method is called after the ad placement is closed. For each call to show
, there will be a call to unityAdsDidFinish
, including all failure scenarios.
Parameter | Description |
---|---|
placementId |
The ad placement identifier. This can be found listed under the Android platform of your project in the Unity Ads dashboard. |
state |
The state in which the ad was finished. See UnityAdsFinishState . |
unityAdsDidStart
(void)unityAdsDidStart:(NSString *)placementId;
This method is called at the start of video playback for the ad campaign being shown.
Parameter | Description |
---|---|
placementId |
The ad placement identifier. This can be found listed under the iOS platform of your project in the Unity Ads dashboard. |
Note: If a video fails to start after the call to show
, this method may not be called. In this case, Unity Ads will skip ahead to call unityAdsDidFinish
with a result of kUnityAdsFinishStateError
.
unityAdsReady
(void)unityAdsReady:(NSString *)placementId;
This method is called when the specified ad placement becomes ready to show an ad campaign.
Parameter | Description |
---|---|
placementId |
The ad placement identifier. This can be found listed under the iOS platform of your project in the Unity Ads dashboard. |