Flutter plugin
This documentation contains information about the Flutter Plugin and integrating the Flutter Plugin with the Mobile SDK.
Get the plugin
The plugin and example application are available in the OneWelcome Identity Platform repository. Download the plugin and example application.
Get the Mobile SDK
To begin, ensure you have access to the Mobile SDK. To obtain credentials, navigate to the Customer Support Portal and submit a request for access.
Configure your project
Configure your native project for the Flutter Plugin to start work.
Project requirements
- Android: Minimum API level 24
- iOS: Minimum iOS version 15
- Flutter: Minimum Flutter version 1.12.0
Add the plugin to your project
To start using the plugin, you need to add the plugin to your project.
- Open
pubspec.yamlfile in your project - Add dependency:
Onegini: ^x.y.z. - Run the
flutter pub getcommand.
Initialize Flutter Plugin
To initialize the Flutter Plugin, call the startApplication method.
Example code to initialize the plugin
await Onegini.instance
.startApplication(
twoStepCustomIdentityProviderIds: ["2-way-otp-api"],
connectionTimeout: 5,
readTimeout: 25,
additionalResourceUrls: [])
.catchError((error) {
print("Initialization failed: " + error.message);
});
Configure the Flutter SDK
The Flutter SDK is a wrapper for the Android and iOS SDKs. For this reason, the wrapper SDKs require access to the native SDKs to function, which can be done through the following steps:
- Navigate to the Customer Support Portal and submit a request for access.
- Use the SDK Configurator to configure the Flutter SDK on your application.
Integrate with Android
To integrate the Flutter Plugin with your Android project:
-
Modify the
android/app/build.gradleandroidsection:lintOptions { abortOnError false } -
Add to the
android->defaultConfigsection:minSdkVersion 23 multiDexEnabled true -
Add to
android/build.gradle [allprojects.repositories]allprojects { repositories { google() jcenter() maven { url "https://thalescpliam.jfrog.io/artifactory/onegini-sdk" credentials { username 'YOUR_USERNAME' password 'YOUR_PASSWORD' } } } } -
Set up the OneWelcome Identity Platform configuration. Generate a
OneginiConfigModelandkeystore.bkswith the Mobile SDK Configurator. -
The SDK introduced significant security improvements by providing two separate versions - production and develop.
Production is a version with full security shields turned on. You won't be able to run the app on the emulator. The developer version has all of the security features turned off and is not meant to be used in production.
To use the developer version, add the following variable in the gradle.properties:
onegini_dev=trueYou are encouraged to use the new version of the SDK configurator 6.0.0 to automatically migrate the ClientConfigModel file into Kotlin and safely remove the SecurityController file.
Caution
Never release your app with the developer version of the SDK (with gradle property
onegini_devset). Doing so can result in a possible data breach and significantly decrease the security level of your app. -
Modify
android/app/src/main/AndroidManifest.xml. Add<intent-filter>to yourMainActivityfor listening browser redirects. Updatescheme="oneginiexample"to use the scheme you generated usingonegini-sdk-configurator.<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="oneginiexample" /> </intent-filter>Note
The Flutter Plugin uses deep links for communication between web pages and your app.
Integrate with iOS
iOS (>= 15.1):
Swift Package Manager
Before integrating SPM Package, run pod install.
-
Open a terminal and run:
swift package-registry set --global https://thalescpliam.jfrog.io/artifactory/api/swift/swift-public swift package-registry login -
Enter your artifactory token:
Enter access token: {YOUR_TOKEN} Login successful. Credentials have been saved to the operating system's secure credential store. Registry configuration updated. -
Open the iOS project in Xcode and select
Pods.xcodeproj. Right-click and selectAdd Package Dependencies.... -
In the search bar, enter the Onegini SDK repository:
OneWelcome.SDKSPM. -
Choose the version
13.0.xwithuptoNextMinorVersionof the SDK and clickAdd Packagefor targetonegini. -
Repeat steps 3 to 5 for
<PROJECT>.xcodeprojfor target<PROJECT>. -
In the terminal, go to the app's directory and run:
xcodebuild -resolvePackageDependenciesNow your dependencies look like this:

CocoaPods
-
The Flutter Plugin is uploaded to the OneWelcome Identity Platform Artifactory repository. To let CocoaPods use an Artifactory repository, you need to install the
cocoapods-artplugin.gem install cocoapods-art -
The OneWelcome Identity Platform repository is not a public repository. You must provide credentials to access the repo. Create a file named
.netrcin your Home folder(~/)and add the following contents to it:machine thalescpliam.jfrog.io login <username> password <password> -
Add the OneWelcome Identity Platform CocoaPods repository to your machine:
pod repo-art add onegini htps://thalescpliam.jfrog.io/artifactory/api/pods/cocoapods-public -
To update the repository, you must manually perform the following update:
pod repo-art update onegini -
Add next to
ios/Podfile(before app target):plugin 'cocoapods-art', :sources => [ 'onegini' ] -
The SDK can detect whether the app works in debug mode or with a debugger attached. This feature is enabled by default. When debug mode detection is enabled and a debugger is detected, the iOS SDK does not allow you to execute any of the user-related flows and returns an error.
To provide the best possible experience during iOS integration and security protection of your product, two types of SDK are provided: production (secure) and develop.
SDK version production develop Debug detection + - Root detection + - Debug logs - + To use the develop version, add the following environment variable in the ios/Podfile:
ENV['ONEGINI_DEV'] = 'true'In Case of SPM, use
OneWelcome.SDKSPM-dev.Caution
Never release your app with the developer version of the SDK (with environment variable
ONEGINI_DEVset orOneWelcome.SDKSPM-devas SPM). Doing so can result in a possible data breach and significantly decrease the security level of your app. -
Run
pod install.
Linking native iOS code
For iOS versions 12.0 and later, to link native code in the xCode project, execute:
cd ios && pod install