Skip to content

iOS SDK Integration Guide

Beta

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+
  • In order for your app to have access to AdGem's offers, you will need to ensure your app is approved in the AdGem system. Please reach out to your dedicated Publisher Support Advocate with any questions.

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.

  1. Install CocoaPods (v1.9 or newer). You can find more information on how to install CocoaPods here.
  2. Edit your Podfile and add the following line:
    pod 'AdGem'
    
  3. Run pod install in your terminal window. Cocoa pods will automatically download the framework and install it into your project.

Manual Download

  1. Download the latest version of the AdGem iOS SDK v2.0.0
  2. 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.

<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 Offer Wall in your project:

AdGem.showOfferwall()

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:

func offerwallLoadingStarted() {}

Called when the offer wall has finished loading on the users device:

func offerwallLoadingFinished() {}

Called when the offer wall has closed on the users device:

func offerwallClosed() {}

Called if the offer wall 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 (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