Integrar el SDK D1 usando Ionic Capacitor
Overview
Capacitor is an open source native runtime for building Web Native apps. With Capacitor, you can create cross-platform iOS, Android, and Progressive Web Apps using JavaScript, HTML, and CSS.
Capacitor is an alternative to Cordova as the runtime environment when developing issuer applications using Ionic.
To integrate D1 SDK using Capacitor, refer to the following sections:
Capacitor Plugin
When integrating third party SDK's and native components, the Android and iOS native projects have to be placed in the respective modules called Plugins, which are then added to the Capacitor project.
Creating Cordova Plugin for D1 SDK
Prerequisites
This guide was tested with:
D1 SDK
4.0.0 Android
4.0.0 iOS
Ionic
Ionic CLI 6.20.8
Angular CLI 16.1.4
Capacitor
Capacitor CLI 5.2.1
Capacitor/android 5.2.1
Capacitor/core 5.2.1
Capacitor/ios 5.2.1
Xcode 14.3.1
To create a template for the Capacitor plugin:
Plugin compilation is done using the following command:
TypeScript interface
After the template is created, the TypeScript method prototypes will be called from the Capacitor project.
The following code snippets show how to create the method prototypes for the Login and Configure use cases.
Android platform
Implementing the Java native plugin entry point
For the TypeScript method prototypes:
Create the appropriate entry point in the Android native code.
To implement the native Android entry point of the plugin, extend the Capacitor Java class
Plugin.
Android default CookieManager
Internally the D1 SDK manages cookies. Capacitor sets the default CookieManager to CapacitorCookieManager, which causes a RuntimeException, which is ignored, but causes the D1 SDK to not return a callback. As a workaround set a standard CookieManager as the default one before configuring the the SDK.
Adding D1 SDK dependencies to the Capacitor plugin
Add the D1 SDK binaries dependencies.
Create the Android modules using D1 SDK.
Add the dependencies to the Capacitor plugin.
NFC Wallet Configuration Files
Add the NFC Wallet configuration files to the Capacitor plugin.
iOS platform
Implement the Swift native plugin entry point
For the TypeScript method prototypes:
Create the appropriate entry point in the iOS native code.
To implement the Native iOS entry point of the plugin, extend the Capacitor Swift class
CAPPlugin.
Export the method prototypes to the Capacitor plugin.
Adding D1 SDK dependencies to the Capacitor plugin module
The most simple way to differentiate between the Debug and Release version of D1 SDK on the iOS platform, is to wrap the D1 SDK binaries in to Pods.
Debug Podspec
Release Podspec
Update the
podspecfile of the Capacitor plugin.
Integrating the Capacitor plugin to Ionic Capacitor application
Adding the D1 Capacitor plugin to your Capacitor project
After all the updates are done, the Capacitor plugin needs to be built.
Add the Capacitor plugin to the Capacitor project. Use the application ID
com.thalesgroup.gemalto.d1.validationfor the sandbox, when creating the Ionic Capacitor application.
Add the Android and iOS platforms.
Synchronize the Capacitor project with the respective platforms.
Access the D1 Capacitor plugin API using TypeScript.
Updating the Capacitor Android application
The following updates are to be applied to the Android platform:
Reference the new Android modules which contain the D1 SDK binaries in the Ionic Capacitor Android application.
Update the minimum SDK version supported to 24.
Set
android:allowBackuptofalse.
As NFC Wallet on the Android platform uses Firebase Cloud Messaging (FCM), Google Messaging Services has to be enabled in the Android application to use FCM.
Add FCM to Ionic application:
Add the
google-services.jsonfile to Android application.
Update application signing keystore. To run the NFC Wallet use case on the Android platform, the application needs to be signed with a specific keystore.
Updating the Capacitor iOS application
Add the Pods for D1 SDK Debug and Release version.
References
D1 portal
Última actualización
¿Te fue útil?