Links

iOS Setup Guide

The HyprMX SDK is designed to present rewarded, interstitial, and banner ads in your application. To integrate the SDK, follow the steps below. If you're upgrading an existing SDK, please refer to the Upgrade Guide.

SDK Integration

The SDK can be integrated using CocoaPods or by Manual Installation.

CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. To integrate the HyprMX SDK with CocoaPods, add the following to your Podfile:
pod 'HyprMX', '6.2.0'
Note: HyprMX 6.0.0+ supports Cocoapods 1.10+

Manual Installation

To manually install the framework, follow the steps below.
1. Download the SDK here and unzip the file.
2. Drag and drop the HyprMX.xcframework (available in the zip) into your Xcode project. Make sure that the files are copied and verify the target membership.
Add HyprMX SDK to your Xcode Project
3. Select your Project File and the Target. In the "General" tab, drag the HyprMX.xcframework from the File Explorer into the "Frameworks, Libraries, and Embedded Content" section.
4. Set the Embed setting to "Embed & Sign".

Xcode Project Setup

Application Transport Security

We recommend that ATS (App Transport Security) settings are turned off as Apple has put on hold their efforts to enforce the policy. In order to do so, add the App Transport Security dictionary key below to your Info.plist.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If you prefer to enable ATS, you must add the three App Transport Security dictionary keys below to your Info.plist to ensure that HyprMX operates properly.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>

Configuring Privacy Controls

iOS requires that the use of a user's camera, photo library, IDFA, etc. be declared by advertisers in the plist. Add all of the following entries to your app's plist.
<key>NSCameraUsageDescription</key>
<string>${PRODUCT_NAME} requests write access to the Camera</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} requests write access to the Photo Library</string>
<key>NSUserTrackingUsageDescription</key>
<string>${PRODUCT_NAME} would like to show you personalized ads</string>

SKAdNetwork Identifier

HyprMX SDK 5.4.0+ supports Apple's new SKAdNetwork for Attribution. To add the HyprMX SKAdNetwork ID to your info.plist:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>nu4557a4je.skadnetwork</string>
</dict>
...
</array>
Note: SKAdNetwork Id's are case sensitive. For more information about SKAdNetwork please refer to Apple's documentation.

Orientation

HyprMX recommends your app support all orientations globally to maximize ad fill, as HyprMX ads may be shown in any orientation, and our view controller needs your app to support that behavior. You can configure this by selecting all possible orientations under the General tab of your Xcode target, or by configuring the supportedInterfaceOrientations in your App Delegate:
Swift
Objective-C
func application(_ application: UIApplication,
supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return .all
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
Please note, this setup does not require that your app's interface support all orientations. You just have to configure your view controllers' orientation settings:
Swift
Objective-C
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscape
}
public override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}

Exporting

When archiving your application for the App Store, Xcode will prompt with an option to Manage Version and Build Numbers:
It is not recommended to select this option since this can modify info.plist files of your third party libraries.

Importing the SDK

To import the HyprMX Mobile SDK into your Application:
Swift
Objective-C
import HyprMX
@import HyprMX;

Initializing HyprMX

All calls to HyprMX must be done from the main thread.
After you have integrated the SDK, proceed to initializing the HyprMX SDK. To initialize, see details below. As a best practice, initialize HyprMX as soon as possible (i.e. when your application is loading) so we can begin preloading ads. Review the details of initialization parameters (distributorID, userID, consentStatus, and ageRestrictedUser) below to find out what initializer best suits your app's use case.

Initialization API

Sample Initializer

Swift
Objective-C
lazy var hyprDelegate = YourHyprInitializationDelegateImplementation()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let distributorId = "Your Distributor ID"
let userId = "Your User's ID"
HyprMX.initialize(withDistributorId: distributorId,
userId: userId,
consentStatus: <HyprConsentStatus>, // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
ageRestrictedUser: false, // If you don't know the user is age restricted, set this to false
initializationDelegate: hyprDelegate)
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.hyprDelegate = [YourHyprInitializationDelegateImplementation new];
NSString *distributorId = @"Your Distributor ID";
NSString *userId = @"Your User's ID";
[HyprMX initializeWithDistributorId:distributorId
userId:userId
consentStatus: // If you don't have consent status for the user, set this to CONSENT_STATUS_UNKNOWN
ageRestrictedUser:NO // If you don't know the user is age restricted, set this to false
initializationDelegate:self.hyprDelegate];
return YES;
}

distributorID (required)

The value for distributorId is assigned to your application by HyprMX. If you have not received this ID, please reach out to your HyprMX account manager.

userID (required)

The user ID is a unique identifier supplied by your application and must be static for each user across sessions. Your user ID should not contain any personally identifiable information such as an email address, screen name, or Apple's Advertising Identifier (IDFA). If you don't have a static identifier, you can use the code snippet below for generating a unique user ID using NSProcessInfo. To change the user ID, you must re-initialize HyprMX.
Swift
Objective-C
let userIdStorageKey = "hyprMarketplaceUserId"
var userId = ""
if let storedUserId = UserDefaults.standard.object(forKey: userIdStorageKey) as? String {
userId = storedUserId
} else {
userId = ProcessInfo.processInfo.globallyUniqueString
UserDefaults.standard.set(userId, forKey: userIdStorageKey)
}
NSString *userIdStorageKey = @"hyprMarketplaceUserId";
NSString *userId = [[NSUserDefaults standardUserDefaults] objectForKey:userIdStorageKey];
if (!userId) {
userId = [[NSProcessInfo processInfo] globallyUniqueString];
[[NSUserDefaults standardUserDefaults] setObject:userId forKey:userIdStorageKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
// initialize HyprMX with userId

consentStatus (optional)

HyprMX provides an Initialization API with a consentStatus parameter with below values for jurisdictions that require passing consent collected by your app. Please refer to our privacy page for more information on consent flag. The initializer takes a HyprConsentStatus value:
  • CONSENT_STATUS_UNKNOWN
  • CONSENT_GIVEN
  • CONSENT_DECLINED
HyprMX also provides a separate method for setting Consent. Use this when a user's consent status changes.
Swift
Objective-C
HyprMX.setConsentStatus(<HyprConsentStatus>)
[HyprMX setConsentStatus:<HyprConsentStatus>];

ageRestrictedUser (optional)

HyprMX provides an Initialization API with an ageRestrictedUser parameter. If the user requires child-directed treatment under applicable laws and policies, set this parameter to true. Otherwise, set it to false. For additional guidelines around this flag, please refer to our privacy page.

Initialization Callbacks

Implement HyprMXInitializationDelegate if you want to get initialization callbacks. HyprMX holds a weak reference to the initialization delegate, so you must be sure to retain the delegate.
Swift
Objective-C
class YourHyprInitializationDelegateImplementation: <superclass>, HyprMXInitializationDelegate {
func initializationDidComplete() {
print("Initialization of HyprMX Completed Successfully")
}
func initializationFailed() {
print("Initilization of HyprMX Failed")
}
}
@implementation YourHyprInitializationDelegateImplementation
- (void)initializationDidComplete {
NSLog(@"Initilization of HyprMX Completed Successfully");
}
- (void)initializationFailed {
NSLog(@"Initilization of HyprMX Failed");
}
@end
After receiving the initializationDidComplete message, you are now ready to load and display ads in your application. See our Rewarded Ads, Interstitial Ads, and Banner Ads guides to add these ad types to your application.
Last modified 2mo ago