API Reference (EN) - imobile-maio/maio-iOS-SDK GitHub Wiki
Maio Class
+ sdkVersion
+ startWithMediaId:delegate:
+ setAdTestMode:
+ setDelegate:
+ canShow
+ canShowAtZoneId:
+ show DEPRECATED
+ showAtZoneId: DEPRECATED
Advanced
+ startWithNonDefaultMediaId:delegate:
+ showWithViewController:
+ showAtZoneId:vc:
MaioDelegate Protocol
- maioDidInitialize
- maioDidChangeCanShow:newValue:
- maioWillStartAd:
- maioDidFinishAd:playtime:skipped:rewardParam:
- maioDidClickAd:
- maioDidCloseAd:
- maioDidFail:reason:
MaioFailReason Enum
MaioInstance Class
Advanced
mediaId
adTestMode
delegate
- canShow
- canShowAtZoneId:
- show DEPRECATED
- showAtZoneId: DEPRECATED
- showWithViewController:
- showAtZoneId:vc:
Maio Class
+ sdkVersion
Get maio SDK version number.
Version
v1.0.7+
Declaration
+ (NSString *)sdkVersion
+ startWithMediaId:delegate:
Initialize the SDK.
Declaration
+ (void)startWithMediaId:(NSString *)mediaId delegate:(id<MaioDelegate>)delegate
Parameters
-
mediaId
The mediaid generated for your application located in the maio dashboard
-
delegate
Delegates to capture SDK events. Use nil if you dont want to capture events.
Example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set SDK to test mode.
[Maio setAdTestMode:YES];
// Start maio SDK initilization.
[Maio startWithMediaId:MAIO_MEDIA_ID delegate:nil];
return YES;
}
+ setAdTestMode:
Returns SDK test mode setting.
Declaration
+ (void)setAdTestMode:(BOOL)adTestMode
Parameters
-
adTestMode
To run the SDK in test mode use YES, otherwise use NO. Set test mode to
YES
while developing your app andNO
once released to Play Store (default value isNO
).
Example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Sets SDK to test mode
[Maio setAdTestMode:YES];
// SDK initialize
[Maio startWithMediaId:MAIO_MEDIA_ID delegate:nil];
return YES;
}
+ setDelegate:
Set delegate to capture SDK events.
Declaration
+ (void)setDelegate:(id<MaioDelegate>)delegate
Parameters
-
delegate
Delegate to capture SDK events
+ canShow
Default zone is ready to show a video ad YES
is returned, else NO
is returned.
Declaration
+ (BOOL)canShow
Example
- (IBAction)onOpenAd:(id)sender {
// Display video ad
if ([Maio canShow]) {
[Maio showWithViewController:self];
}
}
+ canShowAtZoneId:
Specified zone is ready to show a video ad YES
is returned, else NO
is returned.
Declaration
+ (BOOL)canShowAtZoneId:(NSString *)zoneId
Parameters
-
zoneId
ZoneId of the zone you want to display a video ad for.
Example
- (IBAction)onOpenAd:(id)sender {
// Display video ad
if ([Maio canShowAtZoneId:ZONE_ID]) {
[Maio showAtZoneId:MAIO_ZONE_ID vc:self];
}
}
+ show DEPRECATED
Display video ad for default zone.
*Deprecated from v1.5.0. Use showWithViewController:
.
Declaration
+ (void)show
+ showAtZoneId DEPRECATED
Display video ad for specified zone.
*Deprecated from v1.5.0. Use showAtZoneId:vc:
.
Declaration
+ (void)showAtZoneId:(NSString *)zoneId
Parameters
-
zoneId
ZoneId of the zone you want to display a video ad for.
+ startWithNonDefaultMediaId:delegate:
Advanced
Initialize maio MediaId with a different mediaId (Multiple mediaIds).
Mainly used when using maio via a third party library.
Version
v1.1.0+
Declaration
+ (MaioInstance *)startWithNonDefaultMediaId:(NSString *)mediaEid delegate:(id<MaioDelegate>)delegate
Parameters
-
mediaId
The mediaid generated for your application located in the maio dashboard
-
delegate
Delegates to capture SDK events. Use nil if you dont want to capture events.
+ showWithViewController:
Advanced
Explicitly choose which UIViewController to display video ad for default zone.
Version
v1.0.1+
Declaration
+ (void)showWithViewController:(UIViewController *)vc;
Parameters
-
vc
UIViewController instance
Example
- (IBAction)onOpenAd:(id)sender {
// Display video ad
if ([Maio canShow]) {
[Maio showWithViewController:self];
}
}
+ showAtZoneId:vc:
Advanced
Explicitly choose which UIViewController to display video ad for specified zone.
Version
v1.0.1+
Declaration
+ (void)showAtZoneId:(NSString *)zoneEid vc:(UIViewController *)vc;
Parameters
-
zoneId
ZoneId of the zone you want to display a video ad for.
-
vc
UIViewController instance
Example
- (IBAction)onOpenAd:(id)sender {
// Display video ad
if ([Maio canShowAtZoneId:ZONE_ID]) {
[Maio showAtZoneId:MAIO_ZONE_ID vc:self];
}
}
MaioDelegate Protocol
- maioDidInitialize
Called when SDK has inititialized.
Declaration
- (void)maioDidInitialize
- maioDidChangeCanShow:newValue:
Called when SDK status change from Can Show video to Cannot Show Video event.
Declaration
- (void)maioDidChangeCanShow:(NSString *)zoneId newValue:(BOOL)newValue
Parameters
-
zoneId
Status changed zoneId
-
newValue
Current Status.
YES
= Can Show VideoNO
= Cannot Show Video
Example
- (void)maioDidChangeCanShow:(NSString *)zoneId newValue:(BOOL)newValue {
// Toggle buttons validy property depending on whether ads are available or not.
if ([ZONE_ID isEqualToString:zoneId]) {
self.startButton.enabled = newValue;
}
else if ([ZONE_ID_2 isEqualToString:zoneId]) {
self.start2Button.enabled = newValue;
}
}
- maioWillStartAd:
Called when video is about to play. Only called once, not called on replays.
Declaration
- (void)maioWillStartAd:(NSString *)zoneId
Parameters
-
zoneId
ZoneId for ad being played
- maioDidFinishAd:playtime:skipped:rewardParam:
Called when video finished playing. Only called once, not called on replays.
Declaration
- (void)maioDidFinishAd:(NSString *)zoneId playtime:(NSInteger)playtime skipped:(BOOL)skipped rewardParam:(NSString *)rewardParam
Parameters
-
zoneId
ZoneId for ad being played
-
playtime
Amount of seconds video was actually played
-
skipped
If video was skipped
YES
elseNO
-
rewardParam
Reward parameter (when ad type is Reward Video)
Example
- (void)maioDidFinishAd:(NSString *)zoneId playtime:(NSInteger)playtime skipped:(BOOL)skipped rewardParam:(NSString *)rewardParam {
// TODO: Code to give reward
}
- maioDidClickAd:
Called when end card is clicked.
Declaration
- (void)maioDidClickAd:(NSString *)zoneId
Parameters
-
zoneId
ZoneId for ad being clicked
- maioDidCloseAd:
Called when the ad is closed.
Declaration
- (void)maioDidCloseAd:(NSString *)zoneId
Parameters
-
zoneId
ZoneId for closed ad
- maioDidFail:reason:
Called when there is an SDK error.
Declaration
- (void)maioDidFail:(NSString *)zoneId reason:(MaioFailReason)reason
Parameters
-
zoneId
ZoneId that caused error Sometimes nil will be returned if there is no zone, or a network error.
-
reason
Reason for error
MaioFailReason Enum
maio SDK error types
-
MaioFailReasonAdStockOut
Ads out of stock
-
MaioFailReasonNetworkConnection
Network connection error
-
MaioFailReasonNetworkClient
HTTP status 4xx client error
-
MaioFailReasonNetworkServer
HTTP status 5xx server error
-
MaioFailReasonSdk
SDK Error
-
MaioFailReasonDownloadCancelled
Creative download cancelled
-
MaioFailReasonVideoPlayback
Video playback error
-
MaioFailReasonUnknown
Unknown error
MaioInstance Class
Advanced
Version
v1.1.0+
mediaId
Returns maio MediaId
Declaration
@property (nonatomic, readonly) NSString *mediaId
adTestMode
Returns SDK test mode setting.
Declaration
@property (nonatomic) BOOL adTestMode
delegate
Returns maio SDK delegate
Declaration
@property (nonatomic) id<MaioDelegate> delegate
- canShow
Declaration
- (BOOL)canShow
- canShowAtZoneId:
Declaration
- (BOOL)canShowAtZoneId:(NSString *)zoneId
- show DEPRECATED
*Deprecated from v1.5.0. Use showWithViewController:
.
Declaration
- (void)show
- showAtZoneId DEPRECATED
*Deprecated from v1.5.0. Use showAtZoneId:vc:
.
Declaration
- (void)showAtZoneId:(NSString *)zoneId
- showWithViewController:
Declaration
- (void)showWithViewController:(UIViewController *)vc;
- showAtZoneId:vc:
Declaration
- (void)showAtZoneId:(NSString *)zoneEid vc:(UIViewController *)vc;