iOS HyprMX SDK
SDK Documentation
  • Getting Started
    • iOS Setup Guide
    • Privacy
    • Apple App Privacy Details
    • Migrate to Version 6.4+
  • Ad Formats
    • Rewarded Ads
    • Interstitial Ads
    • Banner/MREC Ads
  • 3rd Party Mediation
    • 3rd Party Mediation
      • AdMob Mediation
      • AppLovin MAX
      • Chartboost Mediation
      • Digital Turbine FairBid
      • Unity LevelPlay
      • X3M XMediator
  • Downloads/Change Log
    • Downloads
    • Change Log
      • iOS SDK Change Log
      • iOS AdMob Adapter Change Log
      • iOS MAX Adapter Change Log
Powered by GitBook
On this page
  • SDK Migration
  • CocoaPods
  • Manual Migration
  • Fixing Your Broken Build
  • Migrating HyprMX.initialize
  • Migrating HyprMXPlacement.isAdAvailable
  • Migrating HyprMXPlacement.loadAd
  • Migrating HyprMXPlacementDelegate
  • HyprMXBannerView.loadAd
  • Migration complete.
  1. Getting Started

Migrate to Version 6.4+

Please follow the below guide to migrate from the HyprMX SDK 6.x to 6.4+.

PreviousApple App Privacy DetailsNextRewarded Ads

Last updated 2 months ago

This guide applies to partners upgrading to version 6.4+ from pre-6.4 versions. No migration is needed if you're upgrading from 6.4+.

HyprMX SDK 6.4+ contains a revamp to our public API, streamlining our SDK's initialization and providing more focused callbacks and delegates. Additionally, we now provide modernized asynchronous APIs that you can opt into, and have removed the main thread requirement from all of our public methods.

SDK Migration

The HyprMX iOS SDK 6.x can be migrated to 6.4+ through or by .

CocoaPods

To migrate the HyprMX SDK with CocoaPods, update the pod to 6.4.2 in your Podfile:

pod 'HyprMX', '6.4.2'

Run pod install from the terminal in the directory containing your Podfile.

Manual Migration

To manually migrate the framework, follow the steps below.

1. Download the SDK and unzip the file.

2. Right-click on HyprMX.xcframework in your project navigator and select Show in Finder.

3. Drag and drop the new 6.4+ HyprMX.xcframework (available in the zip) into the folder that contains the 6.3 HyprMX.xcframework and Replace the old one.

Fixing Your Broken Build

See below for migrations related to HyprMX SDK 6.4+.

Migrating HyprMX.initialize

switch await HyprMX.initialize(distributor: distributorId) {
    case .success:
        // successful init logic
    case .failure(let error):
        print(error)
        // failed init logic
}
HyprMX.initialize(distributorId) { success, error in
    if success {
        // successful init logic
    } else {
        print(error)
        // failed init logic
    }
}
[HyprMX initWithDistributorId:distributorId
                   completion: ^(BOOL success, NSError * _Nullable error) {
    if (success) {
        // successful init logic
    } else {
        NSLog(@"%@", [error description]);
        // failed init logic
    }
}];

Other parameters that used to be provided to the initialization API now have new setters. These parameters can now be set after initialization when the information is available. As a result, you will need to migrate the following parameters:

  • consentStatus

  • ageRestrictedUser

  • userID

Follow the steps below to migrate the parameters.

Migrating the consentStatus parameter

HyprMX.setConsentStatus(CONSENT_GIVEN)
// OR
HyprMX.setConsentStatus(CONSENT_DECLINED)
[HyprMX setConsentStatus:CONSENT_GIVEN];
// OR
[HyprMX setConsentStatus:CONSENT_DECLINED];

Migrating the ageRestrictedUser parameter

HyprMX.setAgeRestrictedUser(true)
[HyprMX setAgeRestrictedUser:YES];

Migrating the userID parameter

Our API no longer accepts user ID.

HyprMXInitializationDelegate

HyprMXInitializationDelegate has been replaced with async Result or completion closure. To migrate existing code:

  1. Remove any references to HyprMXInitializationDelegate from your project.

  2. When success is true, call your existing initializationDidComplete method or logic.

  3. When success is false, call your existing initializationFailed method or logic.

switch await HyprMX.initialize(distributor: distributorId) {
    case .success:
        // initializationDidComplete logic
    case .failure(let error):
        print(error)
        // initializationFailed logic
}
HyprMX.initialize(distributorId) { success, error in
    if success {
        // initializationDidComplete logic
    } else {
        print(error)
        // initializationFailed logic
    }
}
[HyprMX initWithDistributorId:distributorId
                   completion: ^(BOOL success, NSError * _Nullable error) {
    if (success) {
        // initializationDidComplete logic
    } else {
        NSLog(@"%@", [error description]);
        // initializationFailed logic
    }
}];

Completion blocks are invoked from the same operation queue the SDK is called from, a slight behavioral difference between the async and completion variants.

Migrating HyprMXPlacement.isAdAvailable

If used in any Swift source files, remove trailing parenthesis from placementInstance.isAdAvailable

Migrating HyprMXPlacement.loadAd

loadAd doesn't use a delegate in HyprMX SDK 6.4+. Instead, it returns results via async result or completion based callbacks. To migrate existing code:

  1. When success is true, invoke your former onAdAvailable implementation.

  2. When success is false, invoke your former onAdNotAvailable implementation.

let success = await placement.loadAd()
if success {
    // ad available logic
} else {
    // not available logic
}
placement.loadAd() { success in
    if success {
        // ad available logic
    } else {
        // not available logic
    }
}
[placement loadAdWithCompletion:^(BOOL success) {
    if (success) {
        // ad available logic
    } else {
        // not available logic
    }
}];

Completion blocks are invoked from the same operation queue the SDK is called from, a slight behavioral difference between the async and completion variants.

Migrating HyprMXPlacementDelegate

HyprMXPlacementDelegate has been renamed to HyprMXPlacementShowDelegate. The SDK takes the delegate as a parameter in showAd, and stops using that delegate instance after calling adDidClose. To migrate existing code:

1. Rename references to HyprMXPlacementDelegate to HyprMXPlacementShowDelegate

class MyPlacementDelegate: NSObject, HyprMXPlacementShowDelegate {
@interface MyPlacementDelegate : NSObject<HyprMXPlacementShowDelegate>

2. Pass the show delegate as the second parameter to showAd

placement.showAd(from: viewController, delegate: showDelegate)
[placement showAdFromViewController:viewController delegate:showDelegate];

3. If you need callbacks to adExpired then implement the HyprMXPlacementExpiredDelegate

class MyPlacementDelegate: NSObject, HyprMXPlacementShowDelegate, 
                                     HyprMXPlacementExpiredDelegate {
@interface MyPlacementDelegate: NSObject<HyprMXPlacementShowDelegate, 
                                         HyprMXPlacementExpiredDelegate>

And set the expired delegate on your placement:

placement.expiredDelegate = placementDelegate
placement.expiredDelegate = placementDelegate;

4. If your project implemented HyprMXPlacementDelegate in Swift, then it needs a few adjustments:

  • Remove for from adWillstart:

//func adWillStart(for placement: HyprMXPlacement) {
func adWillStart(placement: HyprMXPlacement) {
  • Remove for and didFinishAd from adDidClose and replace Any! with Bool

//func adDidClose(for placement: HyprMXPlacement, didFinishAd finished: Any!) {
func adDidClose(placement: HyprMXPlacement, finished: Bool) {
  • Remove adDisplayError(for placement: HyprMXPlacement, error hyprMXError: HyprMXError)

  • Remove Error and the underscore from adDisplayError(_ error: Any!, placement: HyprMXPlacement)

//func adDisplayError(_ error: Any!, placement: HyprMXPlacement)
func adDisplay(error: NSError, placement: HyprMXPlacement)
  • Remove for from adDidReward and replace the two Any! types with String? and Int

//func adDidReward(for placement: HyprMXPlacement, rewardName: Any!, rewardValue: Any!)
func adDidReward(placement: HyprMXPlacement, rewardName: String?, rewardValue: Int)
  • Remove for from adExpired

//func adExpired(for placement: HyprMXPlacement)
func adExpired(placement: HyprMXPlacement)

HyprMX SDK always holds weak references to delegates.

HyprMXBannerView.loadAd

loadAd doesn't use a delegate in HyprMX SDK 6.4+. Instead, it returns results via async or completion based paths. To migrate existing code:

  1. When success is true, invoke your adDidLoad implementation

  2. When success is false, invoke your adFailedToLoad:error: implementation

let success = await bannerView.loadAd()
if success {
    // adDidLoad logic
} else {
    // adFailed logic
}
bannerView.loadAd() { success in
    if success {
        bannerDelegate.adDidLoad(bannerView)
    } else {
        bannerDelegate.adFailed(toLoad: bannerView, error: nil)
    }
}
[bannerView loadAdWithCompletion:^(BOOL success) {
    if (success) {
        [bannerDelegate adDidLoad:placement];
    } else {
        [bannerDelegate adFailedToLoad:placement error:nil];
    }
}];

Migration complete.

The new SDK initializer now only requires a distributorId, and takes a completion closure or returns a depending on the API chosen:

Result
here
CocoaPods
Manual Migration