• Your App needs to formulate a "Privacy Policy", display the "Privacy Policy" when the user launches the App for the first time, and obtain the user's consent. For the "Privacy Policy" formulated by the App, please refer to "Privacy Guide" please make sure that the user agrees to the App's "Privacy Policy" , and then initialize TopOn SDK.
• For EU regions or related user privacy agreement controls, data reporting permissions can be controlled through setGDPRLevel.
• Through setLogEnabled method can enable debugging logs to facilitate locating problems encountered in SDK integration.
• The appid, appkey and other parameters required by the SDK can be obtained through the developer backend after creating the app
You can initialize the SDK through the following code. In addition, since the advertisement is loaded asynchronously, if you want to obtain the status of the advertisement, please implement each Listening methods for advertising types.
Import ATSDK import 'package:anythink_sdk/at_index.dart';
_initTopon() async {
await ATInitManager.initAnyThinkSDK(
appidStr: 'you appid',
appidkeyStr: 'you appkey')
}
Full sample code:
import 'package:anythink_sdk/at_index.dart';
import '../configuration_sdk.dart';
final InitManger = InitTool();
class InitTool{
// Open the Debug log of the SDK. It is strongly recommended that you open it during the test phase to facilitate troubleshooting.
setLogEnabled() async {
await ATInitManger
.setLogEnabled(
logEnabled: true,
);
}
// Set up channels that can be used for statistics and traffic grouping
setChannelStr() async {
await ATInitManger
.setChannelStr(
channelStr: "test_setChannel",
);
}
// Set up sub-channels that can be used for statistics and traffic grouping
setSubchannelStr() async {
await ATInitManger
.setSubChannelStr(
subchannelStr: "test_setSubchannelStr",
);
}
// Configure user-defined Map information to match the traffic group (App latitude) configured in the background. (Optional)
setCustomDataDic() async {
await ATInitManger.setCustomDataMap(
customDataMap: {
'setCustomDataDic': 'myCustomDataDic',
},
);
}
// Set a list of excluded cross-promotion apps
setExludeBundleIDArray() async {
await ATInitManger.setExludeBundleIDArray(
exludeBundleIDList: ['test_setExludeBundleIDArray'],
);
}
// Set the user-defined Map information to match the traffic group (Placement latitude) configured in the background. (Optional)
setPlacementCustomData() async {
await ATInitManger.setPlacementCustomData(
placementIDStr: 'b5b72b21184aa8',
placementCustomDataMap: {'setPlacementCustomData': 'test_setPlacementCustomData'},
);
}
// Determine whether it is located in the European Union
getUserLocation() async {
await ATInitManger.getUserLocation().then((value) {
print('flutter: Get user location -- ${value.toString()}');
});
}
// Obtain the authorization level of the GDPR
getGDPRLevel() async {
await ATInitManger.getGDPRLevel().then((value) {
print('flutter:Get GDPR --${value.toString()}');
});
}
setDataConsentSet() async {
await ATInitManger.setDataConsentSet(
gdprLevel:
ATInitManger.dataConsentSetPersonalized());
}
deniedUploadDeviceInfo() async {
await ATInitManger
.deniedUploadDeviceInfo(
deniedUploadDeviceInfoList: [ATInitManger.aOAID()]);
});
}
// Initialize TopOn's SDK
initTopon() async {
await ATInitManger.initAnyThinkSDK(
appidStr: Configuration.appidStr,
appidkeyStr: Configuration.appidkeyStr);
}
// Show the interface of GDPR (v6.2.87 deprecated, use showGDPRConsentDialog() instead)
showGDPRAuth()async{
await ATInitManger.showGDPRAuth();
}
// v6.2.87+, showing the GDPR interface (UMP)
showGDPRConsentDialog()async{
await ATInitManger.showGDPRConsentDialog();
}
// Get the GDPR listening event callback
initListen() {
ATListenerManager.initEventHandler.listen((value) {
if (value.userLocation != null) {
switch (value.userLocation) {
case InitUserLocation.initUserLocationInEU:
print("flutter Monitor initial user location in the EU--");
ATInitManger.getGDPRLevel().then((value) {
if (value == ATInitManger.dataConsentSetUnknown()) {
showGDPRAuth();
}
});
break;
case InitUserLocation.initUserLocationOutOfEU:
print("flutter: flutter The location of the listening initial user is not in the EU");
break;
case InitUserLocation.initUserLocationUnknown:
print("flutter: flutter The location of the initial listening user is unknown");
break;
}
}
if (value.consentDismiss != null) {
print("flutter: flutter consent dismiss callback");
}
});
}
}
Open the Debug log of the SDK. It is strongly recommended to open it during the testing phase to facilitate troubleshooting.
_setLogEnabled() async {
await ATInitManager
.setLogEnabled(
logEnabled: true,
);
}
_setChannelStr() async {
await ATInitManager
.setChannelStr(
channelStr: "123",
);
}
_setSubchannelStr() async {
await ATInitManager
.setSubchannelStr(
subchannelStr: "456",
);
}
Can match the corresponding traffic grouping (It works for the whole project) configured in the background (optional configuration)
_setCustomDataDic() async {
await ATInitManager.setCustomDataMap(
customDataMap: {
'1': 'a',
},
);
}
Can match the corresponding traffic configured in the background Grouping (Valid for this placement id) (optional configuration)
_setPlacementCustomData() async {
await ATInitManager.setPlacementCustomData(
placementIDStr: '4',
placementCustomDataMap: {'b': '4'},
);
}
Set a list of excluded cross-promotion apps, remove items that do not require advertising promotion, and pass in the items Appid (Apple background id) array.
_setExludeBundleIDArray() async {
await ATInitManager.setExludeBundleIDList(
exludeBundleIDList: ['3'],
);
}
GDPR is the abbreviation of the General Data Protection Regulation issued by the European Union on May 25, 2018. If your project needs to be released in the European Union, please complete the access.
Please refer to Android Google UMP / iOS Google UMP to complete the integration and configuration of UMP, and use the following APIs for UMP GDPR pop-up windows and SDK initialization.
// v6.2.87+, show GDPR (UMP)
showGDPRConsentDialog()async{
await ATInitManger.showGDPRConsentDialog();
}
initListen() {
ATListenerManager.initEventHandler.listen((value) {
//Note: The SDK needs to be initialized in this callback and load ads after initialization.
if (value.consentDismiss != null) {
print("flutter: flutter consent dismiss callback");
}
});
}
Note: You need to initiate an ad request after the SDK is initialized.
_getGDPRLevel() async {
await ATInitManager.getGDPRLevel().then((value) {
print('get GDPR level');
});
}
ATInitManager. dataConsentSetPersonalized(): This level represents the user’s consent to the SDK collecting and using his personal data to provide him with more relevant and more suitable ads.
ATInitManager.dataConsentSetNonpersonalized(): If the data protection level is set to this value, the SDK will not collect user personal data because the provided Advertisements may not be relevant to the user's profile. In addition, in this case, some data that does not involve user privacy may still be collected.
setDataConsentSet() async {
await ATInitManager.setDataConsentSet(
gdprLevel:
ATInitManager.dataConsentSetPersonalized());
}
Determine whether it is located in the EU region, for the EU Processing done during region initialization
_getUserLocation() async {
await ATInitManager.getUserLocation();
}
If you are in the European Union and the level is UNKNOW, execute the authorization pop-up window
showGDPRAuth()async{
await ATInitManager.showGDPRAuth();
}
initListen() {
ATListenerManager.initEventHandler.listen((value) {
switch (value.userLocation) {
case InitUserLocation.initUserLocationInEU:
print("flutter Listen to initialize user location in the EU--");
ATInitManager.getGDPRLevel().then((value) {
if (value == ATInitManager.dataConsentSetUnknown()) {
showGDPRAuth();
}
});
break;
case InitUserLocation.initUserLocationOutOfEU:
print("flutter The listening initialization user is not located in the EU");
break;
case InitUserLocation.initUserLocationUnknown:
print("flutter The location of the listener initialization user is unknown");
break;
}
});
}
Note: When developers limit the reported device data, it may affect the normal use of TopOn functions, such as traffic grouping, cross-promotion, TopOn Adx and other functions. Developers please set it carefully.
deniedUploadDeviceInfo() async {
await ATInitManager
.deniedUploadDeviceInfo(
deniedUploadDeviceInfoList: [
ATInitManager.aVersionNameKey(),
ATInitManager.aVersionCodeKey(),
ATInitManager.aPackageNameKey(),
ATInitManager.aAppVersionNameKey(),
ATInitManager.aAppVersionCodeKey(),
ATInitManager.aBrandKey(),
ATInitManager.aModelKey(),
ATInitManager.aScreenKey(),
ATInitManager.aNetworkTypeKey(),
ATInitManager.aMNCKey(),
ATInitManager.aMCCKey(),
ATInitManager.aLanguageKey(),
ATInitManager.aTimeZoneKey(),
ATInitManager.aUserAgentKey(),
ATInitManager.aOrientKey(),
ATInitManager.aIDFAKey(),
ATInitManager.aIDFVKey(),
ATInitManager.aANDROID(),
ATInitManager.aGAID(),
ATInitManager.aINSTALLER(),
ATInitManager.aMAC(),
ATInitManager.aIMEI(),
ATInitManager.aOAID(),
]);
});
}
Parameter description:
Key | Note |
---|---|
ATInitManager.aVersionNameKey() | System version name |
ATInitManager.aVersionCodeKey() | System version number |
ATInitManager.aPackageNameKey() | Application package name |
ATInitManager.aAppVersionNameKey() | Application version name |
ATInitManager.aAppVersionCodeKey() | Application version number |
ATInitManager.aBrandKey() | Equipment brand |
ATInitManager.aModelKey() | Device model |
ATInitManager.aScreenKey() | Screen resolution |
ATInitManager.aNetworkTypeKey() | Network type |
ATInitManager.aMNCKey() | Mobile network Code |
ATInitManager.aMCCKey( ) | Mobile country code |
ATInitManager.aLanguageKey() | System language |
ATInitManager.aTimeZoneKey() | Time zone |
ATInitManager.aUserAgentKey() | User Agent |
ATInitManager.aOrientKey() | Screen Direction |
ATInitManager.aIDFAKey( ) | idfa |
ATInitManager.aIDFVKey() | idfv |
ATInitManager.aANDROID() | Android ID |
ATInitManager.aGAID() | Google Ad ID |
ATInitManager.aINSTALLER() | Application installation Source |
ATInitManager.aMAC( ) | MAC address |
ATInitManager.aIMEI() | International Mobile Equipment Identity |
ATInitManager.aOAID() | OAID |