Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter doesn't report success #37

Open
deakjahn opened this issue Apr 23, 2024 · 2 comments
Open

Adapter doesn't report success #37

deakjahn opened this issue Apr 23, 2024 · 2 comments

Comments

@deakjahn
Copy link

deakjahn commented Apr 23, 2024

Contrary to what the source says:

// This method won't be called for custom events.
override fun initialize(
context: Context,
initializationCompleteCallback: InitializationCompleteCallback,
list: List<MediationConfiguration>
) {
return
}

it is called, very much so, and expects to be called back as:

initializationCompleteCallback.onInitializationSucceeded()

Otherwise, the GMS will wait for the timeout, note a failure with the adapter and won't use it at all.

So:

  override fun initialize(context: Context, initializationCompleteCallback: InitializationCompleteCallback, list: List<MediationConfiguration>) {
    Log.d(TAG, "initialize()")
    HwAds.init(context);
    initializationCompleteCallback.onInitializationSucceeded()
  }

See the documentation at: https://developers.google.com/ad-manager/mobile-ads-sdk/android/custom-events/setup

@deakjahn
Copy link
Author

deakjahn commented Apr 24, 2024

I fail to see the real reason for BuildConfigMediation at all. The adapter version could be hardwired directly and the SDK version doesn't need to be stored and synchronized manually because it can be queried simply:

  override fun getVersionInfo(): VersionInfo {
    Log.d(TAG, "getVersionInfo()")
    return VersionInfo(2, 0, 1 * 100)
  }

  override fun getSDKVersionInfo(): VersionInfo {
    Log.d(TAG, "getSDKVersionInfo()")

    val versionString: String = HwAds.getSDKVersion()
    val splits = versionString.split(".").toTypedArray()
    return if (splits.size >= 3) {
      val major = splits[0].toInt()
      val minor = splits[1].toInt()
      val micro = splits[2].toInt()
      VersionInfo(major, minor, micro)
    } else
      VersionInfo(0, 0, 0)
  }

Also note that the split() delimiters are wrong.

@deakjahn
Copy link
Author

deakjahn commented Apr 24, 2024

The plugin also needs agconnect-services.json bundled with your app, or at least the relevant data from it. I would suggest a different approach than bundling it and applying the agconnect plugin:

  override fun initialize(context: Context, initializationCompleteCallback: InitializationCompleteCallback, list: List<MediationConfiguration>) {
    Log.d(TAG, "initialize()")
    try {
      AGConnectInstance.initialize(context, AGConnectOptionsBuilder().apply {
        setClientId("xxx")
        setClientSecret("xxx")
        setApiKey("xxx")
        setCPId("xxx")
        setProductId("xxx")
        setAppId("xxx")
        setPackageName("xxx")
      })
      HwAds.init(context);
      initializationCompleteCallback.onInitializationSucceeded()
    }
    catch (e: IOException) {
      initializationCompleteCallback.onInitializationFailed(e.message ?: "")
    }
  }

This, of course, means that you have to copy the source and incorporate it into your own app rather than referencing it on GitHub. Something that I'd suggest, anyway, because of the current errors. You can also hardwire all your other identifiers like your add unit ids, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant