3. Adding Google Play Services Ads Identifier is optional. If the dependency below is included, it is the app developer's responsibility to ensure compliance with all Google Play policies, including, but not limited to, the Families Program.
2. Initialize the HyprMX SDK in your main Activity inside the onCreate method as shown below. As a best practice, initialize HyprMX as soon as possible (i.e. when your application is loading) so we can begin preloading ads.
private HyprMXIf.HyprMXInitializationListener initializationListener = this;
HyprMX.INSTANCE.initialize(this, DISTRIBUTOR_ID, initializationListener);
// or
HyprMX.INSTANCE.initialize(this, DISTRIBUTOR_ID, initResult -> {
// do something
});
val initializationListener: HyprMXIf.HyprMXInitializationListener = this
HyprMX.initialize(this, DISTRIBUTOR_ID, initializationListener)
// or
HyprMX.initialize(this@MainActivity, DISTRIBUTOR_ID) { (isSuccess, message) ->
// do something
}
// or
HyprMX.initialize(this@MainActivity, DISTRIBUTOR_ID) { result ->
// do something
}
context (required)
Your current context instance.
distributorID (required)
The value for distributorID is assigned to your app by HyprMX. If you have not received this ID and your placements information, please reach out to your HyprMX account manager.
If you need to call HyprMx initializer inside a suspending function you can do as below:
val (initSuccess, _) = HyprMX.initialize(this@MainActivity, DISTRIBUTOR_ID)
Initialization Callbacks
initializationListener is the listener for the Initialization Status of the SDK. It will callback to onInitialized as below:
private HyprMXIf.HyprMXInitializationListener initializationListener = new HyprMXIf.HyprMXInitializationListener() {
@Override
public void onInitialized(@NonNull InitResult initResult) {
if(initResult.isSuccess()) {
// do something
}
if(initResult.getMessage() != null) {
// an error was thrown, i.e., isSuccess() == false
}
}
};
val initializationListener: HyprMXIf.HyprMXInitializationListener = object : HyprMXIf.HyprMXInitializationListener {
override fun onInitialized(result: InitResult) {
if(result.success) {
// do something
}
if(!result.message.isNullOrEmpty()) {
// an error was thrown, i.e., success == false
}
}
}
After receiving the onInitialized callback, you are now ready to load and display ads in your application. See our Rewarded Ads, Interstitial Ads, and Banner/MREC Ads guides to add these ad types to your app.
You can convert these callbacks to lambda (Java) or use a high-order function on Kotlin, as shown above in the initialization section.
[Optional] Passing Alternative Identifiers
Alternative/Extended IDs are supported in HyprMX SDK 6.4+.
HyprMX SDK supports the following alternative IDs or extended IDs (EID) to help improve monetization. If applicable, you are responsible for tokenizing IDs before passing them to HyprMX SDK.