AdInstanceManager constructor

AdInstanceManager(
  1. String channelName
)

Implementation

AdInstanceManager(String channelName)
    : channel = MethodChannel(
        channelName,
        StandardMethodCodec(AdMessageCodec()),
      ) {
  channel.setMethodCallHandler((MethodCall call) async {
    VponLogger.i('channel.setMethodCallHandler $call');

    switch (call.method) {
      case 'nativeLog':
        final String message = call.arguments['message'];
        final String type = call.arguments['type'];
        _consoleLog(message, type);

      case 'onAdEvent':
        final int adId = call.arguments['adId'];
        final String eventName = call.arguments['eventName'];

        final Ad? ad = adFor(adId);
        if (ad != null) {
          _onAdEvent(ad, eventName, call.arguments);
        } else {
          VponLogger.e(
              '$Ad with id `$adId` is not available for $eventName.');
        }
        break;

      default:
        break;
    }
  });
}