💡Tips
- HyperBid Flutter SDK supports both Android and iOS platforms
- All global configuration methods (such as
setUserId,setChannel, privacy compliance, etc.) must be called beforeMcSdk.initialize()- It is recommended to configure Preset Strategy to improve ad loading performance on first launch
mc_sdk directory into your project directory (it can be at the same level as the main project or in a subdirectory).pubspec.yaml in your project and add the local dependency:dependencies:
mc_sdk:
path: ../mc_sdk # Relative path pointing to the mc_sdk directory you placed
flutter pub get
import 'package:mc_sdk/mc_sdk.dart';
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.
<mc_sdk directory>/ios/mc_sdk.podspecimport 'package:mc_sdk/mc_sdk.dart'; to locate the SDK directoryOpen 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 codeinto yourPodfile
💡 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)
After editing the Podfile, open the iOS directory in the terminal and run the installation command:
cd ios
pod install --repo-update
If this is not your first time, you may need to delete
Podfile.lockbefore running the command above.
(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.
<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
<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.
<key>GADApplicationIdentifier</key>
<string>Your GADApplicationIdentifier </string>
<!-- The value format above is e.g.: ca-app-pub-9438501426181082~7319780494 -->
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.
#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
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)
If you are using AdMob, you must add the following configuration to AndroidManifest.xml:
<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
Add Flutter SDK ProGuard rules in proguard-rules.pro:
-keep class com.mcsdk.flutterbridge.** { *; }
-keepclassmembers class com.mcsdk.flutterbridge.** {
public *;
}
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):
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");
}
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 |
| 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 |
| Constant | Value | Description |
|---|---|---|
McMediationId.topon |
1 |
TopOn Mediation Platform |
McMediationId.max |
2 |
AppLovin MAX Mediation Platform |
McMediationId.admob |
4 |
Google AdMob Mediation Platform |
It is recommended to configure Preset Strategy to improve ad loading performance on first app launch.