iOS SDK Integration Guide
Requirements
Account Requirements:
- You have an active AdGem Account
- You have added your app to your Account
App Approval:
- Your app has been approved in the AdGem system
By default, your app will not have access to AdGem's offers until you complete the initial integration steps and your app is approved. Contact your dedicated Publisher Support Advocate with any questions about the approval process.
:::
Platform Requirements
iOS SDK Requirements
- iOS 15.8 or higher
- Swift 5 or Objective-C
- Xcode 11 or higher
Integration
Step 0. Create an App Property in the AdGem Publisher Dashboard
Step 0: Create an App Property in AdGem
Before AdGem can populate offers, you need to create an App Property in the AdGem Dashboard.
- Create a Publisher Account in the AdGem Publisher Dashboard
- Register your App Property in Properties & Apps
Contact your dedicated Publisher Support Advocate if you have any questions about setting up your App Property.
Step 1. Install the AdGem iOS SDK
Add the AdGem SDK to your app with Swift Package Manager:
-
In Xcode, choose File > Add Package Dependencies…
-
Enter the package URL:
https://github.com/AdGem/ios-sdk-package -
Select the AdGemSdk library and add it to your app target. Swift Package Manager downloads and links the framework automatically.
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.
<key>AdGemAppID</key>
<integer>ADGEM_APP_ID</integer>
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:
import AdGemSdk
Use the AdGem class to show the Offerwall in your project:
AdGem.showOfferwall()
There is no need to store an instance of AdGem globally. The SDK will cache its instance on the 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 Offerwall starts loading on the user's device:
func offerwallLoadingStarted() {}
Called when the Offerwall has finished loading on the user's device:
func offerwallLoadingFinished() {}
Called when the Offerwall has closed on the user's device:
func offerwallClosed() {}
Called if the Offerwall has failed to load due to an error:
func offerwallLoadingFailed(error: Error) {}
Called to reward the user with your type of currency:
func offerwallRewardReceived(amount: Int) {}
Step 5. Set the Player ID
IMPORTANT: The Player ID is Required
The player_id parameter must be set with a unique identifier for each user in your application. This identifies the player so that virtual currency can be attributed to their account via the postback request. The player ID must remain constant for each unique player to:
- Prevent players from completing an offer more than once
- Ensure players receive their rewards correctly
Missing Player ID
Tracking URL clicks that do not contain a player_id value will be redirected to a 404 error page.
Player ID Structure Requirements
| Requirement | Details |
|---|---|
| Case | Letters must be lowercase |
| Characters | Alphanumeric characters, hyphens, and underscores only |
| Max Length | 256 characters |
| Forbidden | Emojis, special characters, uppercase letters |
Good Examples:
abc-123-efg-456user_12345player-a1b2c3d4
Bad Examples:
aBc-123-Efg-456(contains uppercase)player@123!(contains special characters)user-😀(contains emoji)
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)
Additional Information
Sample Apps
Sample iOS applications with implementations in both Swift and Objective-C can be found on GitHub.
Optional Parameters
All parameter names and their values are case-sensitive.
You can optimize your revenue potential by segmenting your users using the optional parameters available in the iOS SDK, such as age, gender, level, and custom fields. These values can be retrieved on each conversion postback and used to segment your audiences.
Postback Setup
If you have opted for a "Server Postback", on each successful offer completion by a user AdGem will send a server postback to your server. See Postbacks to learn more.