Core Component
1. Introductionβ
The Component addressed in the current document is called Core Component. This component is mandatory installation, regardless of the use case, as it contains generic functionality to the entire sdk, as well as allowing the use of more specific components.
1.1 Minimum requirementsβ
The minimum native version (Android and iOS) of the SDK are as follows:
- Minimum Android version: 24 - JDK 17
- Minimum Build Tools version: 8.1.4
- Minimum Kotlin Android version: 1.9.0
- Minimum iOS version: 13
- Minimum Flutter version: 3.0
Regarding the architecture of the mobile device:
- armeabi-v7, x86, arm64 and x64
1.2 Plugin versionβ
The current plugin version can be checked as follows:
- Look for the pubspec.yaml file at the root of the plugin.
- The KEY/TAG version indicates the version.
1.3 Plugin installation: Androidβ
1.3.1 Permissions for geolocationβ
Because the Tracking component has geolocation options, it is necessary to add permissions for this. In the AndroidManifest add the following permissions:
<!-- Always include this permission -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Include only if your app benefits from precise location access. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2. Session initialisationβ
2.1 Initialisationβ
βΉοΈ All the configuration can be found in the component's node_modules/@facephi/sdk-core-react-native/src/src/index.tsx file.
Each component has a controller that will allow access to its functionality. Before they can be used, they must be properly initialised. This initialisation must be done as soon as possible, preferably at the application init. Moreover, once all the operations are finished, and the interaction with the SDK Mobile is over, the session must be closed (section 6).
β οΈ This controller SDKController it will be used for every Component call.
There are currently two ways to inject the licence:
- a. Online: Obtaining the licence through a service using a URL and a API-KEY
- b. Offline: Injecting the licence as String
In both cases, the result will be returned through a Promise containing an object CoreResult. More information will be added in section 5.
a. Injecting the licence as Stringβ
You can assign the licence directly as a String, as follows:
Future<Either<Exception, CoreResult>> initSession() async
{
try
{
FphiSdkmobileCore core = FphiSdkmobileCore();
String lic = (Platform.isAndroid) ? LICENSE_ANDROID : LICENSE_IOS;
final Map resultJson = await core.initSession(widgetConfigurationJSON: CoreConfigurationInitSession(
mLicense: lic,
mEnableTracking: true
));
return Right(CoreResult.fromMap(resultJson));
} on Exception catch (e) {
return (Left(e));
}
}
b. Obtaining the licence through a serviceβ
Through a service that will simply require a URL and an API-KEY as an identifier. This would avoid problems when manipulating the licence, as well as the constant substitution of said licences when a problem arises in this regard (malformation or improper modification, licence expiry...):
Future<Either<Exception, CoreResult>> initSession() async
{
try
{
FphiSdkmobileCore core = FphiSdkmobileCore();
String apiKey = (Platform.isAndroid) ? LICENSE_APIKEY_ANDROID : LICENSE_APIKEY_IOS;
final Map resultJson = await core.initSession(widgetConfigurationJSON: CoreConfigurationInitSession(
mLicenseUrl: "https://***.***.pro",
mLicenseApiKey: apiKey,
mEnableTracking: true
));
return Right(CoreResult.fromMap(resultJson));
} on Exception catch (e) {
return (Left(e));
}
}
2.2 Init session configurationβ
In the previous section, there is a class called InitSessionConfiguration that customises the current session. The properties of this class are the following:
2.2.1 licenseβ
type: string
Sets the SDK Mobile license. This license is provided by Facephi.
mLicense: "valid licenseβ
2.2.2 licenseUrlβ
type: string
Sets the url where the service remotely validates the current license. This endpoint is provided by Facephi (online license).
mLicenseUrl: "https://***.***.pro"