I am working on a flutter app which requires the help of some native Android codes. To be more specific, I want to integrate an ad network named "IronSource" to serve ads in my app. But currently they do not provide a library for flutter so I wrote the required codes in java language and did a platform call to show an ad. The ad is showing successfully but I have a problem on how to listen to their callback methods that they have provided.
I will post what I have tried so far.
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
new MethodCallHandler() {
@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("loadInterstitialAd")) {
IronSource.loadInterstitial();
} else {
result.notImplemented();
}
}
});
The above method will listen to the channel and will load the ad. However, these are some of the callback methods that are available in native library:
public void onInterstitialAdLoadFailed
public void onInterstitialAdOpened()
public void onInterstitialAdClosed()
public void onInterstitialAdShowSucceeded()
and so on...
Now I do not understand how to access these methods in flutter and write my own code.
Any idea/suggestion would be appreciated.
Thanks