initSdk method

  1. @override
Future<void> initSdk(
  1. String appKey,
  2. bool privacy,
  3. bool ccpa,
  4. bool coppa,
  5. bool gdpr,
)
override

Implementation

@override
Future<void> initSdk(
    String appKey, bool privacy, bool ccpa, bool coppa, bool gdpr) async {
  String methodChannelName = methodChannel.name;
  log('Yodo1 Flutter Plugin registering channel name $methodChannelName');
  methodChannel.setMethodCallHandler((call) {
    String method = call.method;
    log('Yodo1 Flutter Plugin method call: $method');
    switch (method) {
      case Yodo1MasConstants.methodFlutterInitEvent:
        {
          bool successful;
          if (defaultTargetPlatform == TargetPlatform.android) {
            Map<String, dynamic> map = json.decode(call.arguments);
            successful = map["successful"];
          } else {
            successful = call.arguments["successful"];
          }
          if (_initCallback != null) {
            _initCallback!(successful);
          }
          return Future<bool>.value(true);
        }
      case Yodo1MasConstants.methodFlutterAdEvent:
        {
          int type, code;
          String message;
          if (defaultTargetPlatform == TargetPlatform.android) {
            Map<String, dynamic> map = json.decode(call.arguments);
            type = map["type"];
            code = map["code"];
            message = map["message"] ?? '';
          } else {
            type = call.arguments["type"];
            code = call.arguments["code"];
            message = call.arguments["message"] ?? '';
          }

          log('Yodo1 Flutter event type: $type');
          log('Yodo1 Flutter event code: $code');
          log('Yodo1 Flutter event message: $message');

          switch (type) {
            case Yodo1MasConstants.adTypeReward:
              if (_rewardCallback != null) {
                _rewardCallback!(code, message);
              }
              break;
            case Yodo1MasConstants.adTypeInterstitial:
              if (_interstitialCallback != null) {
                _interstitialCallback!(code, message);
              }
              break;
            case Yodo1MasConstants.adTypeAppOpen:
              if (_appOpenCallback != null) {
                _appOpenCallback!(code, message);
              }
              break;
            case Yodo1MasConstants.adTypeNative:
              if (_nativeCallback != null) {
                _nativeCallback!(code, message);
              }
              break;
            case Yodo1MasConstants.adTypeBanner:
              if (_bannerCallback != null) {
                _bannerCallback!(code, message);
              }
              break;
          }
        }
    }
    return Future<bool>.value(true);
  });

  await methodChannel.invokeMethod(Yodo1MasConstants.methodNativeInitSdk, {
    'app_key': appKey,
    'privacy': privacy,
    'ccpa': ccpa,
    'coppa': coppa,
    'gdpr': gdpr,
  });
}