Flutter SDK Integration
Before you startMake sure you've obtained a token, server URL, and auth key from your credolab Customer Success Manager.
The minimal supported version of Dart SDK is 2.19.6 or higher
The minimal supported version of Flutter is 3.7.12 or higher
The minimal supported iOS version is 11.0 or higher
iOS Iovation plugin requires the minimum iOS version15.0.Android Iovation plugin requires the minimum API level
24(Android 7.0).
The minimal supported Android API version is 21 or higher
1. Declare dependencies
Add the dependencies to pubspec.yaml. Replace X.Y.Z with the actual plugin versions:
dependencies:
flutter_core:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_core
version: X.Y.Z
flutter_android_account:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_account
version: X.Y.Z
flutter_android_contact:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_contact
version: X.Y.Z
flutter_android_telephony:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_telephony
version: X.Y.Z
flutter_android_calendar:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_calendar
version: X.Y.Z
flutter_android_audio:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_audio
version: X.Y.Z
flutter_android_video:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_video
version: X.Y.Z
flutter_android_images:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_images
version: X.Y.Z
flutter_android_guard:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_guard
version: X.Y.Z
flutter_ios_contact:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_contact
version: X.Y.Z
flutter_ios_calendar_events:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_calendar_events
version: X.Y.Z
flutter_ios_calendar_reminders:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_calendar_reminders
version: X.Y.Z
flutter_ios_media:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_media
version: X.Y.Z
flutter_ios_music:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_music
version: X.Y.Z
flutter_ios_application:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_ios_application
version: X.Y.Z
flutter_behavioral:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_behavioral
version: X.Y.Z
flutter_android_behavioral_phone:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_behavioral_phone
version: X.Y.Z
flutter_android_behavioral_guard:
hosted:
url: https://dart.cloudsmith.io/credolab/hybrid/
name: flutter_android_behavioral_guard
version: X.Y.ZOpen a terminal window on the root path of your project and execute:
flutter pub getAdd repositories for Android
Add the credolab Maven repository to android/build.gradle or, in newer projects, android/build.gradle.kts (replace $TOKEN with the actual value):
allprojects {
repositories {
// ...
maven { url "https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/" }
}
}allprojects {
repositories {
// ...
maven { url = uri("https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/") }
}
}Add repositories for iOS
The credolab iOS SDK is distributed through a private Cloudsmith repository. Configure it for the dependency manager your project uses (replace $TOKEN with the actual value).
Swift Package Manager
Swift Package Manager (on by default since Flutter 3.44; on Flutter 3.24 - 3.43 enable it with flutter config --enable-swift-package-manager). Requires plugin versions 9.0.0 or higher and an iOS deployment target of 12.0 or higher. Register the credolab Swift package registry once on each build machine:
swift package-registry set https://swift.cloudsmith.io/credolab/proxyen-sdk/ --scope credolab --global
swift package-registry login https://swift.cloudsmith.io/credolab/proxyen-sdk/ --token $TOKENSwift Package Manager on CI without keychain access
To authenticate without the keychain (for example, on a CI runner), run these commands instead:
swift package-registry set https://swift.cloudsmith.io/credolab/proxyen-sdk/ --scope credolab --global
swift package-registry login https://swift.cloudsmith.io/credolab/proxyen-sdk/ --token $TOKEN --disable-keychain --netrc --no-confirm
chmod 600 ~/.netrc
defaults write com.apple.dt.Xcode IDEPackageAuthorizationProviderOverride -string netrcCocoaPods
CocoaPods (Flutter below 3.24, or Swift Package Manager disabled with flutter config --no-enable-swift-package-manager or enable-swift-package-manager: false under flutter: config: in pubspec.yaml). Add the CocoaPods repository to the beginning of the ios/Podfile file:
source 'https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/cocoapods/index.git'
Unable to find a specification forlibrary_name?Once a custom
sourceis added, CocoaPods no longer uses the public CocoaPods repository by default. If other pods in your project come from it, add the CocoaPods CDN to thePodfileas well:source 'https://cdn.cocoapods.org/'
2. Build and Use CredoAppService
CredoAppServiceIn your Flutter code, open the file where CredoAppService will be used.
- Add plugin imports
import 'package:flutter_core/credo_app_service.dart';
import 'package:flutter_android_account/module.dart';
import 'package:flutter_android_audio/module.dart';
import 'package:flutter_android_video/module.dart';
import 'package:flutter_android_images/module.dart';
import 'package:flutter_android_calendar/module.dart';
import 'package:flutter_android_contact/module.dart';
import 'package:flutter_android_telephony/module.dart';
import 'package:flutter_android_guard/module.dart';
import 'package:flutter_ios_contact/module.dart';
import 'package:flutter_ios_calendar_reminders/module.dart';
import 'package:flutter_ios_calendar_events/module.dart';
import 'package:flutter_ios_music/module.dart';
import 'package:flutter_ios_media/module.dart';
import 'package:flutter_ios_application/module.dart';
import 'package:flutter_behavioral/module.dart';
import 'package:flutter_behavioral/behavioral/credoapp_behavioral.dart';
import 'package:flutter_behavioral/behavioral/credoapp_navigator_observer.dart';
import 'package:flutter_android_behavioral_phone/module.dart';
import 'package:flutter_android_behavioral_guard/module.dart';- Call
addModule(MODULE_NAME)to add a module andcollect()to start the data collection process:
Future<void> collectData() async {
// init CredoAppService
var service = CredoAppService();
service.setForceResolvePermissions(true);
service.setIgnorePermissions(true);
// add modules
await service.addModule(AndroidVideoModule());
await service.addModule(AndroidCalendarModule());
await service.addModule(AndroidContactModule());
await service.addModule(AndroidImagesModule());
await service.addModule(AndroidAudioModule());
await service.addModule(AndroidAccountModule());
await service.addModule(AndroidGuardModule());
await service.addModule(IosContactModule());
await service.addModule(IosCalendarEventsModule());
await service.addModule(IosCalendarRemindersModule());
await service.addModule(IosMusicModule());
await service.addModule(IosMediaModule());
await service.addModule(IosApplicationModule());
await service.addModule(BehavioralModule());
// collect data
final result = await service.collect();
if(result.isFailure){
print("Error: ${result.code} ${result.message}");
}else{
result.value // this is dataset -> now upload collected data to credolab servers
}
}
// If the BehavioralModule is included, then wrap the root app widget with the CredoAppBehavioral widget
void main() {
runApp(CredoAppBehavioral(
key: Key("root_layout"),
startTracking: true, // Set `true` to initiate behavioral data tracking on application start, or set `false` and call BehavioralModule.startTracking() method manually in anywhere in your code
child: const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [
CredoAppNavigatorObserver.create(), // add credoapp navigation observer
],
home: const MyHomePage(title: 'Home Page'),
);
}
}
// Add Phone Behavioral Plugin (optional)
// Make sure you add Phone Behavioral plugin after READ_PHONE_STATE successful permission request
// Or call the method on the app startup if permission is already granted
if(Platform.isAndroid){
BehavioralModule.addPlugin(AndroidPhoneBehavioralPlugin());
BehavioralModule.addPlugin(AndroidGuardBehavioralPlugin());
}
// Stop the behavioral tracking to conserve resources or mark the end of a user flow
BehavioralModule.stopTracking()
Note - Behavioral modulePlease refer to
BehavioralModulesection for additional information about module integration.
Behavioral data is cleared oncollect()method callOnce the
collect()method is called,BehavioralModuleclears the data stored on the user's device.Thus, for data consistency, our strong recommendation is to call the method only once: at the end of the user flow.
Note - Application moduleTo integrate the
IosApplicationModulemodule, first add URL schemes to theInfo.plistfile of your project (a maximum of 50 schemes is allowed).Please refer to the native module integration where the default list is specified.
3. Upload from a Mobile Device (Testing purposes only)
Direct Upload Note:In a production environment, datasets should only be uploaded via your organization's proxy server.
For testing, integration, or generating insights, you may use the following code snippet:
Next Steps
After successfully integrating our SDK, it is recommended to proceed with the following steps to utilize our platform effectively:
- Setting up your Reverse Proxy
- Uploading your Dataset. Once the server is configured, you can upload your dataset using the server address.
- Collecting your Dataset Insight or TruValidate (formerly known as Iovation) Fraud Check. With the dataset uploaded, you can now get insights or perform TruValidate Fraud Checks to assess risk based on the device and transaction details provided.
If you have any further questions, please do not hesitate to contact us.
Updated 7 days ago

