iOS SDK Integration Guide
Before you Begin
- You must have an active AdGem Account
- You must add your App to your Account
- The AdGem iOS SDK supports devices iOS 15.0 and higher
- The AdGem iOS SDK can be integrated using Swift 5 or Objective-C and requires XCode 11+
Step 1. Install the AdGem iOS SDK
There are two ways to add the AdGem SDK to your iOS app. We recommend that you use the CocoaPods approach, but you can also download it and add it manually if you prefer.
CocoaPods Integration Method: (Recommended)
- Install CocoaPods (v1.9 or newer). You can find more information on how to install CocoaPods here.
- Edit your Podfile and add the following line:
pod installin your terminal window. Cocoa pods will automatically download the framework and install it into your project.
- Download the latest version of the AdGem iOS SDK v1.5.0
- Drag the AdGemSdk.xcframework folder into the Frameworks, Libraries, and Embedded Content section in Xcode
Step 2. Add Initialization Code
- In your AppDelegate.swift file, import the AdGem SDK by adding this line:
Also in the AppDelegate.swift file add the following line of code to your
AdGem.startSession(appId: **ADGEM_APP_ID**, usesStandardVideo: false, usesRewardedVideo: false, usesOfferwall: true)
Replace ADGEM_APP_ID with the AdGem app ID from the AdGem publisher dashboard.
The boolean variables
usesOfferwallare for the ad units you plan to use.
Step 3. Ad Units
To trigger the Offer Wall, use the follow code:
To trigger a standard video ad, use the follow code:
To trigger a rewarded video ad, use the follow code:
Step 4. Delegate Methods
The following delegate methods are available:
Called when the offer wall starts loading on the users device:
Called when the offer wall has finished loading on the users device:
Called when the offer wall has closed on the users device:
Called if the offer wall has failed to load due to an error:
Called to reward the user with your type of currency:
Called when the User finishes watching a video ad:
Called when videos are downloaded and ready to be played:
Called when the video starts playing on the user’s device:
Called when the user clicks on an ad from a video:
Called when a video ad fails to load due to an error:
Step 5. Set the player id (for non games, the unique identifier for a user)
For increased fraud protection, we highly recommend you set the playerId (a unique id for your user) parameter.
Sample iOS applications with implementations both in Swift and Objective-C can be found on Github.
You can optimize your revenue potential by segmenting your users using the optional parameters available in the iOS SDK. Please visit Optional Parameters to learn more.
If you have opted for a “Server Postback”, on each successful offer completion by a user AdGem will send a GET request to your server. Please visit our guide on Server Postback Setup to learn more.
Updated on March 23, 2023