Menu

SDK-Import-and-Initialization

💡Tips

  • HyperBid Flutter SDK supports both Android and iOS platforms
  • All global configuration methods (such as setUserId, setChannel, privacy compliance, etc.) must be called before McSdk.initialize()
  • It is recommended to configure Preset Strategy to improve ad loading performance on first launch

1. Import Flutter SDK


1.1 Manual Import

  1. Download the HyperBid Flutter SDK archive and extract it.
  2. Place the extracted mc_sdk directory into your project directory (it can be at the same level as the main project or in a subdirectory).
  3. Find pubspec.yaml in your project and add the local dependency:
yaml Copy
dependencies:
  mc_sdk:
    path: ../mc_sdk  # Relative path pointing to the mc_sdk directory you placed
  1. Run the dependency installation:
bash Copy
flutter pub get
  1. Import the header in your Dart code:
dart Copy
import 'package:mc_sdk/mc_sdk.dart';

2. Import iOS Adapters

2.1 Prerequisites

  • Latest version of Xcode
  • Latest version of CocoaPods installed
  • iOS minimum deployment target is 13.0

2.2 Locate the Correct mc_sdk.podspec File

mc_sdk.podspec is located in the ios/ directory of the Flutter SDK. Flutter's Plugin mechanism will automatically reference this file, and you do not need to modify it manually.

  • If you manually imported the Flutter SDK: The target file is located at <mc_sdk directory>/ios/mc_sdk.podspec
  • To verify the podspec path: In your IDE, hover over import 'package:mc_sdk/mc_sdk.dart'; to locate the SDK directory

2.3 Add iOS Adapter Dependencies in the Podfile

Open your main project's ios/Podfile, and add the HyperBid core SDK and required Ad Network adapters inside the target 'Runner' do block:

You can obtain them from HyperBid Tools SDK Download.

(1). Select the SDK version

(2). Select the Mediation Platform

(3). Select the Ad Network

(4). Click to generate the integration code

(5). Copy the generated CocoaPods reference code into your Podfile

💡 Tips

  • Please refer to the SDK Download Center for the latest version numbers
  • Uncomment the Ad Network adapters you need to integrate
  • If using MAX mediation, some Ad Networks require an additional AppLovin Mediation Adapter (e.g., AppLovinMediationVungleAdapter)
  • If using AdMob mediation, some Ad Networks require an additional Google Mediation Adapter (e.g., GoogleMobileAdsMediationVungle)

2.4 Install iOS Dependencies

After editing the Podfile, open the iOS directory in the terminal and run the installation command:

bash Copy
cd ios
pod install --repo-update

If this is not your first time, you may need to delete Podfile.lock before running the command above.


3. Configure the iOS Project

3.1 Update Your Info.plist

(1) Open Info.plist

(2) Add the SKAdNetworkItems key

The SKAdNetwork ID for UnityAds is different for each project. If you selected this Ad Network, please use the one generated from the UnityAds dashboard. You need to visit the UnityAds management console to check.

Please go back to the "SDK Download Center" webpage mentioned above, and add the content listed in the "SKAdNetwork IDs Code" section to your Info.plist file. Please refer to the image below:

(3) Add the LSApplicationQueriesSchemes key

Please go back to the "SDK Download Center" webpage mentioned above, or directly copy the code below, and add the content listed in the following section to your Info.plist file. Please refer to the image below:

(4) Add the NSUserTrackingUsageDescription key

  • Starting from iOS 14.5, apps can only access the user's IDFA data and deliver targeted ads with the user's explicit permission.
  • The IDFA will not be available until the application presents an app tracking authorization request to the end user via the App Tracking Transparency framework. If an app does not make this request, the IDFA returned will be a string of all zeros.
markup Copy
<key>NSUserTrackingUsageDescription</key>
<string>Modify this to the permission request description you want the user to see, can be localized</string>

(5) Add the NSAppTransportSecurity key

markup Copy
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

(6) Add the GADApplicationIdentifier key for the AdMob platform

As required by AdMob, add this key only if you have selected this platform. For more information, please visit here.

markup Copy
<key>GADApplicationIdentifier</key>
<string>Your GADApplicationIdentifier </string>
<!-- The value format above is e.g.: ca-app-pub-9438501426181082~7319780494 -->

3.2 Request App Tracking Permission from the User to Obtain IDFA

You need to request app tracking permission from the user through App Tracking Transparency.

  • Before using the method below, you need to set the NSUserTrackingUsageDescription key in the Info.plist file.
  • If your project needs to support GDPR or Google UMP, please go here to configure.
    On iOS 15 and above, this API will only prompt for authorization when the application state is UIApplicationStateActive. If another permission request is pending user confirmation, the authorization prompt will not be displayed.
objc Copy
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>

// If using AppDelegate
@implementation AppDelegate
 
- (void)applicationDidBecomeActive:(UIApplication *)application {
    if (@available(iOS 14, *)) {
        // iOS 14
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {

        }];
    } else {
        // Can be obtained directly
        NSString * idfaStr = [ASIdentifierManager sharedManager].advertisingIdentifier.UUIDString;
    }
}

@end

4. Configure the Android Project

4.1 Import Android Adapters

In the main project's android/app/build.gradle, add the Gradle reference code provided by HyperBid:

After generating the Gradle reference code from the SDK Download Center, add the required Maven repositories and dependencies in android/app/build.gradle:

💡 Tips

  • Please refer to the SDK Download Center for the latest version numbers
  • Uncomment the Ad Network adapters you need to integrate
  • If using MAX mediation, some Ad Networks require an additional AppLovin Mediation Adapter (e.g., com.applovin.mediation:vungle-adapter)
  • If using AdMob mediation, some Ad Networks require an additional Google Ads Mediation Adapter (e.g., com.google.ads.mediation:vungle)

4.2 AndroidManifest Configuration

If you are using AdMob, you must add the following configuration to AndroidManifest.xml:

xml Copy
<manifest>
    <application>
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
    </application>
</manifest>

For details, refer to the AdMob configuration documentation: Update your AndroidManifest.xml

4.3 SDK ProGuard Configuration

Add Flutter SDK ProGuard rules in proguard-rules.pro:

Copy
-keep class com.mcsdk.flutterbridge.** { *; }
-keepclassmembers class com.mcsdk.flutterbridge.** {
   public *;
}

5. SDK Initialization

Before loading ads, you need to complete SDK initialization. It is recommended to call it as early as possible at app startup (e.g., in main() or in the initState of the home page):

dart Copy
import 'package:mc_sdk/mc_sdk.dart';

Future<void> initializeSdk() async {
  // ==========================================
  // Global Configuration (must be called before initialize)
  // ==========================================

  // Enable Debug logging (for development only, disable before release)
  McSdk.setVerboseLogging(true);

  // ==========================================
  // Execute Initialization
  // ==========================================

  McSdk.initialize("your app id", "your app key");
  
}

6. Global API Reference

6.1 Global Configuration Methods

The following methods must be called before McSdk.initialize():

Method Description
McSdk.setVerboseLogging(bool) Enable/disable Debug log output
McSdk.setUserId(String) Set user ID for custom traffic segmentation
McSdk.setChannel(String) Set channel name for analytics
McSdk.setSubChannel(String) Set sub-channel name for analytics
McSdk.setCustomRule(Map) Set custom rules for traffic segmentation
McSdk.setMuted(bool) Set whether video ads are muted by default
McSdk.setHasUserConsent(bool) GDPR: Set whether the user consents to personalized ads
McSdk.setIsAgeRestrictedUser(bool) COPPA: Set whether the user is an age-restricted user
McSdk.setDoNotSell(bool) CCPA: Set whether the user opts out of personal data sale
McSdk.setPrivacySettingEnable(bool) UMP: Enable Google User Messaging Platform integration

6.2 Methods Available After Initialization

Method Return Type Description
McSdk.getMediationConfig() Future<String?> Get the current mediation config (JSON string)
McSdk.showMediationDebugger(int) void Show the Mediation Platform debug tool

6.3 Mediation Platform ID Constants

Constant Value Description
McMediationId.topon 1 TopOn Mediation Platform
McMediationId.max 2 AppLovin MAX Mediation Platform
McMediationId.admob 4 Google AdMob Mediation Platform

7. Preset Strategy

It is recommended to configure Preset Strategy to improve ad loading performance on first app launch.


Previous
Flutter
Next
Ad-Formats
Last modified: 2026-06-25Powered by