MoPub Unity Adapter

Introduction

The HyprMX Unity MoPub Adapter allows you to integrate HyprMX in your MoPub rewarded, interstitial, and banner waterfalls.
  • Android: Compatible with MoPub 5.16.0+
  • iOS: Compatible with MoPub 5.13.1+
The HyprMX Unity Plugin requires CocoaPods version 1.10 or newer installed in your development environment.

Upgrading to 6.0.1.1

  1. 1.
    Delete the previous HyprMXMoPub plugin from your project.
    1. 1.
      Note: Confirm that HyprMXMoPub/Editor/EmbedHyprMXBinary.cs is removed from your project - this editor script is no longer used by the plugin.
  2. 2.
    Update your iOS Resolver Settings to embed Dynamic Frameworks - see iOS Configuration below

Integrating HyprMX In Your Unity Project

  • Download the Adapter Plugin file below.
HyprMX-MoPub-Plugin-6.0.1.1.unitypackage
736B
Binary
HyprMX-MoPub Unity
  • Open your existing application in the Unity IDE.
  • Choose Assets > Import Package > Custom Package... to bring up the File Explorer (Windows) or Finder (Mac).
  • Select the HyprMX Unity MoPub Adapter package, and the Import Unity Package dialog box displays, with all the items in the package pre-checked and ready to install.
  • Android: If the External Dependency Resolver did not automatically resolve the HyprMX dependencies upon import, select Assets > External Dependency Manager > Android Resolver > Resolve.
  • iOS: If the External Dependency Resolver did not automatically resolve the HyprMX dependencies upon import, select Assets > External Dependency Manager > iOS Resolver > Install Cocoapods.

Pre-Initialization

Add the following to your SdkConfiguration before you initialize MoPub with the configuration object. See Initialize Custom Ad Networks in the MoPub documentation.
1
MoPub.InitializeSdk(new MoPub.SdkConfiguration {
2
AdUnitId = anyAdUnitId,
3
4
// Set desired log level here to override default level of MPLogLevelNone
5
LogLevel = MoPub.LogLevel.Debug,
6
7
// Uncomment the following line to allow supported SDK networks to collect user information on the basis
8
// of legitimate interest.
9
//AllowLegitimateInterest = true,
10
11
// Specify the mediated networks you are using here:
12
MediatedNetworks = new MoPub.MediatedNetwork[]{
13
new MoPub.MediatedNetwork {
14
// Specify the class name that implements the AdapterConfiguration interface.
15
#if UNITY_ANDROID
16
AdapterConfigurationClassName = "com.mopub.mobileads.HyprMXAdapterConfiguration", // include the full package name.
17
#else // UNITY_IOS
18
AdapterConfigurationClassName = "HyprMXAdapterConfiguration",
19
#endif
20
21
// Fill in settings and configuration options the same way as for supported networks:
22
NetworkConfiguration = new Dictionary<string,string> {
23
{ "distributorId", "YOUR_DISTRIBUTOR_ID" },
24
{ "userId", "YOUR_USER_ID" }, // Optional key-value pair
25
},
26
}
27
}
28
});
Copied!
If you do not want to include a User ID, initialize the MoPub.MediatedNetwork without the "userId" key-value pair:
1
new MoPub.MediatedNetwork {
2
// Specify the class name that implements the AdapterConfiguration interface.
3
#if UNITY_ANDROID
4
AdapterConfigurationClassName = "com.mopub.mobileads.HyprMXAdapterConfiguration", // include the full package name.
5
#else // UNITY_IOS
6
AdapterConfigurationClassName = "HyprMXAdapterConfiguration",
7
#endif
8
9
// Fill in settings and configuration options the same way as for supported networks:
10
NetworkConfiguration = new Dictionary<string,string> {
11
{ "distributorId", "YOUR_DISTRIBUTOR_ID" },
12
},
13
}
Copied!

Integrating HyprMX On The MoPub Dashboard Using Custom Events

1. Create a custom native network campaign in the MoPub dashboard.
2. When setting up your line item, select 'Network' for the 'Type' field and then select 'Custom Native Network' for the 'Network' field. Further instructions for adding a network account can be found here.
3. In the parameter field, enter the distributor ID and placement name assigned to you by your HyprMX account manager.{ "distributorID": "YOUR_DISTRIBUTOR_ID", "placementName": "YOUR_PLACEMENT_NAME"}
4. For Rewarded video, paste the following class name as the Custom Event class:
Android:
com.mopub.mobileads.HyprMXRewardedVideo
iOS:
HyprMXRewardedVideoCustomEvent
5. For Interstitial, paste the following class name as the Custom Event class:
Android:
com.mopub.mobileads.HyprMXInterstitial
iOS:
HyprMXInterstitialCustomEvent
6. For Banner, paste the following class name as the Custom Event class:
Android:
com.mopub.mobileads.HyprMXBanner
iOS:
HyprMXBannerCustomEvent

Android Configuration

If you are using gradle build tools prior to 4.0 MoPub recommends adding the following to your gradle.properties file to prevent a build error:
1
android.enableDexingArtifactTransform=false
Copied!
To maximize fill rates we also recommend to add the VIBRATE permission, add the following to your AndroidManifest.xml:
1
<uses-permission android:name="android.permission.VIBRATE" />
Copied!

iOS Configuration

  • Configure your iOS Resolver settings to embed Dynamic Frameworks:
    • Open Assets -> External Dependency Manager -> iOS Resolver -> Settings
    • Enable "Always add the main target to Podfile"
  • If you prefer to enable ATS, uncheck the "Allow Downloads over HTTP" checkbox in Player Settings.
  • When the checkbox is unchecked, add the following keys to the exported iOS project's Info.plist:
    • NSAllowsArbitraryLoads
    • NSAllowsArbitraryLoadsForMedia
    • NSAllowsArbitraryLoadsInWebContent

Configuring Privacy Controls

iOS requires that the use of a user's camera, calendar, photo library, idfa, etc. be declared by advertisers in the plist. Add all of the following entries to your app's plist.
1
<key>NSCameraUsageDescription</key>
2
<string>${PRODUCT_NAME} requests write access to the Camera</string>
3
<key>NSCalendarsUsageDescription</key>
4
<string>${PRODUCT_NAME} requests access to the Calendar</string>
5
<key>NSPhotoLibraryUsageDescription</key>
6
<string>${PRODUCT_NAME} requests access to the Photo Library</string>
7
<key>NSPhotoLibraryAddUsageDescription</key>
8
<string>${PRODUCT_NAME} requests write access to the Photo Library</string>
9
<key>NSUserTrackingUsageDescription</key>
10
<string>${PRODUCT_NAME} would like to show you personalized ads</string>
Copied!
Note: Photo Usage and the Photo Add Usage keys are required by the framework to ensure all rich media advertisements are supported.

SKAdNetwork Identifier

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

Deprecated: HyprMXGlobalMediationSettings (iOS)

License

By integrating the HyprMX SDK, you are agreeing to the End User License Agreement.
Last modified 1mo ago