MethodChannelMohoflutterplugin constructor
MethodChannelMohoflutterplugin()
Implementation
MethodChannelMohoflutterplugin() {
methodChannel.setMethodCallHandler((call) async {
debugPrint("广告$call");
if(call.method == 'onAdEvent'){
final String adId = call.arguments["adId"]??"";
final String eventName = call.arguments['onEventName']??"";
final String extra = call.arguments['extra']??"";
if(!methodCall.containsKey(adId)){
return ;
}
var handlerMethod=methodCall[adId];
if(handlerMethod==null){
return ;
}
switch(eventName){
case "onLoadSuccess":
handlerMethod.onLoadSuccess(adId);
debugPrint("广告加载成功");
case "onLoadError":
handlerMethod.onLoadError(adId,extra);
methodCall.remove(adId);
debugPrint("广告加载失败!");
break;
case "onAdShow":
handlerMethod.onAdShow(adId);
debugPrint("广告曝光");
break;
case "onAdClicked":
handlerMethod.onAdClicked(adId);
debugPrint("广告点击");
break;
case "onRenderingError":
handlerMethod.onRenderingError(adId,extra);
methodCall.remove(adId);
debugPrint("广告渲染失败");
break;
case "onAdVideoComplete":
handlerMethod.onAdVideoComplete(adId);
debugPrint("广告视频播放完成");
break;
case "onRewardVerify":
handlerMethod.onRewardVerify(adId);
debugPrint("广告激励回调");
break;
case "onAdClose":
handlerMethod.onAdClose(adId);
methodCall.remove(adId);
debugPrint("广告关闭");
break;
default:
debugPrint("广告其它回调");
}
}
});
}