Appstock SDK is a native library that monetizes iOS applications. The latest SDK version is 1.0.6.
The minimum deployment target is iOS 12.0.
Demo applications (Swift, ObjC): https://public-sdk.al-ad.com/ios/appstock-demo/demo-app-1.0.6/demo-app-1.0.6.zip
Follow the integration instructions to add the SDK to your app. Once the SDK is integrated, you can provide configuration options that will help increase your revenue. Keep in mind that the SDK supports basic consent providers according to industry standards.
Appstock SDK supports the following ad formats:
The SDK can be integrated directly into your app or via supported Mediation Adapters:
Appstock SDK is available for integration via CocoaPods dependency manager and direct download of the compiled framework.
We assume the CocoaPods dependency manager has already been integrated into the project. If not, follow the “Get Started” instructions on cocoapods.org.
Add this line into your Podfile within the application target:
pod 'AppstockSDK', '1.0.6'
Then run pod install --repo-update
.
The Appstock SDK is also available via a direct download link: https://public-sdk.al-ad.com/ios/appstock-sdk/1.0.6/AppstockSDK.xcframework.zip
Import the Appstock SDK core class in the main application class:
import AppstockSDK
Initialize Appstock SDK in the
application:didFinishLaunchingWithOptions
method by
calling Appstock.initializeSDK()
method.
Swift
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize SDK SDK.
.initializeSDK(with: PARTNER_KEY)
Appstock}
Objective-C
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
// Initialize SDK SDK.
[Appstock initializeSDKWithPartnerKey:PARTNER_KEY];
return YES;
}
The Appstock.initializeSdk()
method has a parameter:
It is recommended that contextual information be provided after initialization to enrich the ad requests. For this purpose, use SDK parametrization properties.
Once SDK is initialized and all needed parameters are provided, it is ready to request the ads.
To load a banner ad, create a AppstockAdView
object,
configure it, add it to the view hierarchy, and call its
loadAd()
method.
Swift
private var adView: AppstockAdView!
private func loadAd() {
// 1. Create a AppstockAdView
= AppstockAdView(
adView : CGRect(origin: .zero, size: CGSize(width: 300, height: 250))
frame)
// 2. Configure the AppstockAdView
.placementID = placementID
adView.delegate = self
adView
// Add Appstock ad view to the app UI
.addSubview(adView)
containerAdView
// 3. Load the ad
.loadAd()
adView}
Objective-C
@property (nonatomic) AppstockAdView * adView;
- (void)loadAd {
// 1. Create a AppstockAdView
self.adView = [[AppstockAdView alloc] initWithFrame:CGRectMake(0, 0, 300, 250)];
// 2. Configure the AppstockAdView
self.adView.placementID = self.placementID;
self.adView.delegate = self;
// Add Appstock ad view to the app UI
[self.containerAdView addSubview:self.adView];
// 3. Load the ad
[self.adView loadAd];
}
The AppstockAdView
should be provided with one of the
required configuration properties:
Which one to use depends on your type of Appstock account.
You should also provide CGRect
value for ad view to
initialize UIView
.
If you need to integrate video ads, you can also use the
AppstockAdView
object in the same way as for banner
ads. The single required change is you should explicitly set the ad
format via the respective property:
Swift
.adFormat = .video adView
Objective-C
self.adView.adFormat = AppstockAdFormat.video;
Once it is done, the TeqBlzae SDK will make ad requests for video placement and render the respective creatives.
You can optionally subscribe to the ad’s lifecycle events by
implementing the AppstockAdViewDelegate
protocol:
Swift
extension BannerAdViewController: AppstockAdViewDelegate {
func adViewPresentationController() -> UIViewController? {
// View controller used by SDK for presenting modal.
// Usual implementation may simply return self,
// if it is view controller class.
self
}
func adView(_ adView: AppstockAdView, didFailToReceiveAdWith error: any Error) {
// Called when SDK failed to load ad
("Did fail to receive ad with error: \(error.localizedDescription)")
print}
func adView(_ adView: AppstockAdView, didReceiveAdWithAdSize adSize: CGSize) {
// Called when ad is loaded
}
func adViewWillPresentModal(_ adView: AppstockAdView) {
// Called when modal is about to be presented
}
func adViewDidDismissModal(_ adView: AppstockAdView) {
// Called when modal is dismissed
}
func adViewWillLeaveApplication(_ adView: AppstockAdView) {
// Called when the application is about to enter the background
}
}
Objective-C
@interface AppstockBannerAdViewController : UIViewController <AppstockAdViewDelegate>
@end
// ...
- (UIViewController *)adViewPresentationController {
// View controller used by SDK for presenting modal.
// Usual implementation may simply return self,
// if it is view controller class.
return self;
}
- (void)adView:(AppstockAdView *)adView didFailToReceiveAdWith:
(NSError *)error {
// Called when Appstock SDK failed to load ad
NSLog(@"Did fail to receive ad with error: %@", error.localizedDescription);
}
- (void)adView:(AppstockAdView *)adView
didReceiveAdWithAdSize:(CGSize)adSize {
// Called when ad is loaded
}
- (void)adViewWillPresentModal:(AppstockAdView *)adView {
// Called when modal is about to be presented
}
- (void)adViewDidDismissModal:(AppstockAdView *)adView {
// Called when modal is dismissed
}
- (void)adViewWillLeaveApplication:(AppstockAdView *)adView {
// Called when the application is about to enter the background
}
The refreshInterval
property controls the frequency of
automatic ad refreshes. This interval is set in seconds and dictates
how often a new ad request is made after the current ad is
displayed.
Swift
.refreshInterval = 30.0 adView
Objective-C
adView.refreshInterval = 30.0;
You can stop auto refresh by calling respective method:
Swift
.stopAutoRefresh() adView
Objective-C
[adView stopAutoRefresh];
You can also set adPosition
property to specify the
position of the ad on the screen and corresponding value will be
sent in bidRequest.imp[].banner.pos
ORTB field during
bid request.
Swift
.adPosition = .footer adView
Objective-C
adView.adPostion = AppstockAdPositionFooter;
To load interstitial ads, you should create and configure the
AppstockInterstitialAdUnit
and call its
loadAd()
method.
Swift
private var interstitialAdUnit: AppstockInterstitialAdUnit!
private func loadAd() {
// 1. Create a AppstockInterstitialAdUnit
= AppstockInterstitialAdUnit()
interstitialAdUnit
// 2. Configure the AppstockInterstitialAdUnit
.placementID = placementID
interstitialAdUnit.delegate = self
interstitialAdUnit
// 3. Load the interstitial ad
.loadAd()
interstitialAdUnit}
Objective-C
@property (nonatomic) AppstockInterstitialAdUnit * interstitialAdUnit;
- (void)loadAd {
// 1. Create a AppstockInterstitialAdUnit
self.interstitialAdUnit = [[AppstockInterstitialAdUnit alloc] init];
// 2. Configure the AppstockInterstitialAdUnit
self.interstitialAdUnit.placementID = self.placementID;
self.interstitialAdUnit.delegate = self;
// 3. Load the interstitial ad
[self.interstitialAdUnit loadAd];
}
If you need to integrate video ads or multiformat ads, you should set the adFormats property to the respective value:
Swift
// Make ad request for video ad
.adFormats = [.video]
interstitialAdUnit
// Make ad request for both video and banner ads (default behaviour)
.adFormats = [.video, .banner]
interstitialAdUnit
// Make ad request for banner ad
.adFormats = [.banner] interstitialAdUnit
Objective-C
// Make ad request for video ad
interstitialAdUnit.adFormats = [NSSet setWithArray:@[AppstockAdFormat.video]];
// Make ad request for both video and banner ads (default behaviour)
interstitialAdUnit.adFormats = [NSSet setWithArray:@[AppstockAdFormat.video, AppstockAdFormat.banner]];
// Make ad request for banner ad
interstitialAdUnit.adFormats = [NSSet setWithArray:@[AppstockAdFormat.banner]];
You can check if the ad is ready to be shown by calling respective property:
Swift
if interstitialAdUnit.isReady {
// Show the ad...
}
Objective-C
if (interstitialAdUnit.isReady) {
}
Once the ad is loaded, you can invoke the show()
method
at any appropriate point of the app flow to present the fullscreen
ad. To know when the ad is loaded, you should implement
AppstockInterstitialAdUnitDelegate
protocol and
subscribe to the ad events in its methods.
When the delegate’s method interstitialDidReceiveAd
is
called, it means that the SDK has successfully loaded the ad.
Starting from this point, you can call the
show()
method to display the full-screen ad.
Swift
extension AppstockBannerInterstitialViewController:
AppstockInterstitialAdUnitDelegate {
func interstitialDidReceiveAd(_ interstitial: AppstockInterstitialAdUnit) {
// Called when ad is loaded
// Show the full screen ad
if interstitialAdUnit.isReady {
.show(from: self)
interstitial}
}
func interstitial(
_ interstitial: AppstockInterstitialAdUnit,
didFailToReceiveAdWithError error: (any Error)?
) {Called when Appstock SDK failed to load ad
// print("Did fail to receive ad with error:
(String(describing: error?.localizedDescription))")
\
}
func interstitialWillPresentAd(_ interstitial: AppstockInterstitialAdUnit) {
// Called when interstitial is about to be presented
}
func interstitialDidDismissAd(_ interstitial: AppstockInterstitialAdUnit)
{
// Called when interstitial is dismissed
}
func interstitialDidClickAd(_ interstitial: AppstockInterstitialAdUnit) {
// Called when interstitial was clicked
}
func interstitialWillLeaveApplication(_ interstitial:
AppstockInterstitialAdUnit) {
// Called when the application is about to enter the background
}
}
Objective-C
@interface AppstockBannerInterstitialViewController : UIViewController <AppstockInterstitialAdUnitDelegate>
@end
// ...
- (void)interstitial:(AppstockInterstitialAdUnit *)interstitial didFailToReceiveAdWithError:(NSError *)error {
// Called when Appstock SDK failed to load ad
NSLog(@"Did fail to receive ad with error: %@", error.localizedDescription);
}
- (void)interstitialDidReceiveAd:(AppstockInterstitialAdUnit *)interstitial {
// Called when ad is loaded
[interstitial showFrom:self];
}
- (void)interstitialWillPresentAd:(AppstockInterstitialAdUnit *)interstitial {
// Called when interstitial is about to be presented
}
- (void)interstitialDidDismissAd:(AppstockInterstitialAdUnit *)interstitial {
// Called when interstitial is dismissed
}
- (void)interstitialDidClickAd:(AppstockInterstitialAdUnit *)interstitial {
// Called when interstitial was clicked
}
- (void)interstitialWillLeaveApplication:(AppstockInterstitialAdUnit *)interstitial {
// Called when the application is about to enter the background
}
The following properties enable rendering customization of video interstitial ads.
Property | Description |
---|---|
isMuted |
This option lets you switch the sound on or off during
playback. Default is false .
|
closeButtonArea |
This setting determines the percentage of the device screen
that the close button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
closeButtonPosition |
This setting controls where the close button appears on the
screen. Allowed values: topLeft ,
topRight . Other values will be ignored. Default
is topRight .
|
skipButtonArea |
This setting determines the percentage of the device screen
that the skip button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
skipButtonPosition |
This control sets the position of the skip button. Allowed
values: topLeft , topRight . Other
values will be ignored. Default is topLeft .
|
skipDelay |
This setting determines the number of seconds after the start
of playback before the skip or close button should appear.
Default value is 10.0 .
|
isSoundButtonVisible |
This option switches on or off the visibility of the
sound/mute button for users. Default value is
false .
|
Usage example:
Swift
.isMuted = true
interstitialAdUnit.closeButtonArea = 0.2
interstitialAdUnit.closeButtonPosition = .topRight
interstitialAdUnit.skipButtonArea = 0.2
interstitialAdUnit.skipButtonPosition = .topLeft
interstitialAdUnit.skipDelay = 15.0
interstitialAdUnit.isSoundButtonVisible = true interstitialAdUnit
Objective-C
interstitialAdUnit.isMuted = YES;
interstitialAdUnit.closeButtonArea = 0.2;
interstitialAdUnit.closeButtonPosition = AppstockPositionTopRight;
interstitialAdUnit.skipButtonArea = 0.2;
interstitialAdUnit.skipButtonPosition = AppstockPositionTopLeft;
interstitialAdUnit.skipDelay = 15.0;
interstitialAdUnit.isSoundButtonVisible = YES;
To load rewarded ads, you should create and configure the
AppstockRewardedAdUnit
and call its
loadAd()
method.
Swift
private var rewardedAdUnit: AppstockRewardedAdUnit!
private func loadAd() {
// 1. Create a AppstockRewardedAdUnit
= AppstockRewardedAdUnit()
rewardedAdUnit
// 2. Configure the AppstockRewardedAdUnit
.placementID = placementID
rewardedAdUnit.delegate = self
rewardedAdUnit
// 3. Load the rewarded ad
.loadAd()
rewardedAdUnit}
Objective-C
@property (nonatomic) AppstockRewardedAdUnit * rewardedAdUnit;
- (void)loadAd {
// 1. Create a AppstockRewardedAdUnit
self.rewardedAdUnit = [[AppstockRewardedAdUnit alloc] init];
// 2. Configure the AppstockRewardedAdUnit
self.rewardedAdUnit.placementID = self.placementID;
self.rewardedAdUnit.delegate = self;
// 3. Load the rewarded ad
[self.rewardedAdUnit loadAd];
}
If you need to integrate video ads or multiformat ads, you should set the adFormats property to the respective value:
Swift