Skip to content

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.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.

  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 v1.5.3
  2. Drag the AdGemSdk.xcframework folder into the Frameworks, Libraries, and Embedded Content section in Xcode

Step 2. Add Initialization Code

  1. In your AppDelegate.swift file, import the AdGem SDK by adding this line:
    import AdGemSdk
  2. Also in the AppDelegate.swift file add the following line of code to your didFinishLaunchingWithOptions function.

    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 usesStandardVideo, usesRewardedVideo, and usesOfferwall are 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:

func adGemOfferwallStartedLoading() {}

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

func adGemOfferwallFinishedLoading() {}

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

func adGemOfferwallClosed() {}

Called if the offer wall has failed to load due to an error:

func adGemOfferwallFailedToLoad(error: Error) {}

Called to reward the user with your type of currency:

func adGemRewardUser(amount: Int) {}

Called when the User finishes watching a video ad:

func adGemVideoAdFinishedPlaying(cancelled: Bool)  {}

Called when videos are downloaded and ready to be played:

func adGemDidFinishingCaching() {}

Called when the video starts playing on the user’s device:

func adGemVideoAdStartedPlaying() {}

Called when the user clicks on an ad from a video:

func adGemVideoDidClickAfterVideo() {}

Called when a video ad fails to load due to an error:

func adGemVideoFailedToLoad(errorMessage: String) {}

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.

AdGem.setPlayerId(playerId: "PLAYER123")

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 March 18, 2024

Back to top