iOS SDK Integration Guide
Joining the Beta
AdGem's iOS SDK package is currently in a beta status. If you would like to join the beta program and utilize this integration type, please feel free to provide your Integration Specialist with feedback. If you do not wish to use the Beta iOS SDK package, you can use our full web offerwall integration to create a similar user experience.
Requirements
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.8 and higher
- The AdGem iOS SDK can be integrated using Swift 5 or Objective-C and requires XCode 11+
SDK Integration
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:
- Run
pod install
in your terminal window. Cocoa pods will automatically download the framework and install it into your project.
Manual Download
- Download the latest version of the AdGem iOS SDK v2.0.0
- Drag the AdGemSdk.xcframework folder into the Frameworks, Libraries, and Embedded Content section in Xcode
Step 2. Configure the AdGem SDK
Add a new AdGemAppID key to the app's Info.plist file replacing ADGEM_APP_ID with your AdGem app ID from the AdGem publisher dashboard.
Step 3. Use the AdGem class
All communication with the SDK happens via the AdGem class. In order to access it the following import directive is required:
Use the AdGem class to show Offer Wall in your project:
Please note there is no need to store instance of AdGem globally. The SDK will cache its instance on a first call and will always return the same one for all subsequent calls to AdGem
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:
Step 5. Set the player id (the unique identifier for a user)
For increased fraud protection, we require you set the playerId (a unique id for your user) parameter.
let metaData = AdGemPlayerMetadata.Builder
.initWithPlayerId(playerId: "abc123")
.playerAge(age: 20)
.playerGender(gender: .male)
.playerLevel(level: 5)
.playerPlacement(place: 1000)
.playerPayer(spentMoney: true)
.playerIAPTotal(iapTotal: 10.0)
.playerCreatedAt(creationDate: someDateTime!)
.customField1(field: "custom_field_1")
.customField2(field: "custom_field_2")
.customField3(field: "custom_field_3")
.customField4(field: "custom_field_4")
.customField5(field: "custom_field_5")
.build()
AdGem.setPlayerMetaData(metaData: metaData)
Addtional Information
Sample Apps
Sample iOS applications with implementations both in Swift and Objective-C can be found on Github.
Optional Parameters
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.
Postback Setup
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 September 11, 2024