ReactNative
Using the native iOS/Android WebView implies some extra setup in your ReactNative project. This setup involves incorporating the IntelliProve plug-in Mobile SDK files into your project dependencies for both iOS and Android and adding the necessary bridging code.
All this is nicely laid out in our step-by-step guide below.
The integration guide covers three sections:
- Setting up the iOS code
- Setting up the Android code
- Interfacing with the Native code from ReactNative (bridging)
Our GitHub repository provides a fully functional example of our platform's integration, demonstrating the seamless setup and utilisation of our native SDKs for iOS and Android platforms.
For this guide, we assume a minimal 'Hello World' application generated by the ReactNative project initialisation.
- Add folder ios/Frameworks
- Copy the unzipped IntelliProveSDK.xcframework folder into this folder
- Open the ios/[PROJECT_NAME].xcodeproj project in XCode
- Open Project Settings > General and in the Frameworks, Libraries, and Embedded Content section, add the IntelliProveSDK.xcframework that you copied above as a dependency
- In Project Settings > Build Settings tab, verify that the iOS Deployment Target is set appropriately. The minimum supported version for the IntelliProveSDK is iOS 15.0
- Now open the Project Settings > Info tab to add the following Info.plist value:
- NSCameraUsageDescription - Add a String here that will be displayed when the application asks the user for Camera Usage permissions
- In the project tree, add a new header file called WebViewModule.h, and add the following code:
- Next to that file, add an ObjectiveC file WebViewModule.m:
- Now open AppDelegate.m in the project tree and add the registerWebViewModule method as described below (note the changes in the applicationselector):
- All the following actions are taken in the android root folder of the ReactNative project
- Add folder app/libs
- Copy the IntelliProveWebView.aar into this folder
- In app/build.gradle, add a dependency for the IntelliProveWebView.aarand androidx's AppCompatibility ConstraintLayout.
- In build.gradle (not app/build.gradle), ensure the correct Kotlin version is used, and define the minSdkVersion:
- In app/src/main/AndroidManifest.xml, add the needed permissions for Camera and Internet usage, and an activity tag, so the IntelliWebViewActivity can be shown in the application:
- Find the folder where the MainApplication of the project is located (for example: app/src/main/java/[packagename]/MainApplication.kt
- Now we'll add the React NativeModule that acts as a bridge between ReactNative and Android, add a new file WebViewModule.kt in this same folder:
- In the same folder still, add another file IntelliReactPackage.kt to register the WebViewModule on the application in a 'ReactPackage':
- Finally, open the MainApplication.kt that initializes the ReactNative application in Android. Add the following code to register the Package we created above:
While many possibilities exist to bridge the gap between Native iOS/Android and ReactNative, this document serves as a guide to integrating the IntelliProveSDK into a ReactNative application project.
To be able to call functions on, and receive callbacks from the Native application, we can implement NativeModules in the ReactNative Application.
- Open App.tsx (or wherever in the ReactNative app that the IntelliProve web view will be used)
- Add the following imports:
- Add a function handleOpenWebView that calls the NativeModules to present the Web View
- Also add a callback handler for receiving 'PostMessage' messages.
- The post messages allow you to track the progress of the Face Scan and obtain the results from the IntelliProve plug-in immediately after the user has performed the Face Scan. This allows you to use the results in your mobile app, enabling you to link actions to the results or design a custom results screen.
- Finally, we call the handleOpenWebView()function from wherever the entry point to the WebView should be. The URL to open the IntelliProve WebApp including the action_token is also passed to this function. In our example, it is added on a Button press handler:
The WebView is automatically dismissed by the SDK when receiving the dismiss post message.
- To match the plug-in with your brand's colours and fonts, please visit our Customisation documentation.