Welcome to our new developer portal! Use the "Ask" button to chat with our AI Agent.

Integrar el SDK D1 con React Native

Overview

React Native combines native Android and iOS application development with the JavaScript library React to build user interfaces.

To integrate D1 SDK using React Native, refer to the following sections:

Integrating a Native SDK to a React Native Application

In React Native, the Android and iOS platforms are generated only once.

There are two ways to integrate third party SDKs and native components:

  • A simple approach: Update the generated native projects directly.

  • A more modular and universal approach: Create a standalone module, which is then linked and added to the React Native application.

For simplicity, this guide will focus only on the first option.

Integrating D1 SDK to a React Native Application

This guide was tested with:

  • D1 SDK

    • 4.0.0 Android

    • 4.0.0 iOS

  • React

    • React 18.2.0

    • React Native 0.72.1

  • Xcode 14.3.1

  • Android Studio: 2022.1

To create a new React Native application:

Android platform

1

Add the D1 SDK binaries to the generated Android project.

2

Update the minimum SDK version supported to 24.

3

Add the NFC Wallet configuration files.

For more information, see NFC Wallet configuration files.

4

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.

5

Update the Android package ID.

To be able to configure the D1 SDK on the Android platform for the Push Provisioning use case, the application ID needs to be registered for Google Pay. Use the application ID com.thalesgroup.gemalto.d1.validation for the sandbox environment.

6

Add Firebase Cloud Messaging.

As NFC Wallet on the Android platform uses Firebase Cloud Messaging (FCM), Google Messaging Services has to be enabled in the Android application and the google-services.json file needs to be added.

Add the google-services.json to the Android project: D1ReactExample/android/app/google-services.json.

7

Add the Host APDU Service Resource File.

For more information, see Host APDU service resource file.

9

Implement the Native Android entry point of the plugin by extending the React Java class ReactContextBaseJavaModule.

The following code snippet shows how to implement the methods for the Login and Configure use cases.

10

Register the native module.

iOS platform

1

Add the D1 SDK binaries to the generated iOS project.

a. Copy the SDK folder to the generated iOS project.

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

b. Update the application Podfile.

2

Set ENABLE_BITCODE.

Set ENABLE_BITCODE=NO in the Build Options of each target.

3

Implement the native iOS entry point of the plugin.

The following code snippets show how to create the method prototypes for the Login and Configure use cases.

4

Export the method prototypes to React Native.

Calling the D1 Plugin API from the React Native Project

After the native parts for the Android and iOS platform have been added to the React Native project, the D1 API can be accessed from the React Native project.

References

Última actualización

¿Te fue útil?