Module Integration

lucra-react-native-sdk

Pre-Installation

The package works in both the new and old architecture.

You will need to specify our private native dependencies as they are hosted in GitHub packages. There are two ways to install a private dependency.

You need to create a Personal Access Token (PAT)

Managing Personal Access Tokensarrow-up-right

Select "Classic" with the packages:read and repo permissions enabled and name it Lucra Token. When installing the native dependencies you will be prompted for your username and this token. In case you are setting up a CI system you will also have to use this token in a combination with a username.

Installation

NPM

After you have your token you need to create a .npmrc file at the root of your project and you need to tell the package needs to be fetched from the github registry:

//npm.pkg.github.com/:_authToken=GITHUB_PERSONAL_TOKEN
@lucra-sports:registry=https://npm.pkg.github.com

Install the package to your React Native Repo by running:

Usually you don't want to commit this file into the git repo history. So it's better to add it to your gitignore and each user on your organization has their own file and CI as well.

Integrating with an Expo React Native App

This section provides instructions on how to integrate Lucra SDK into your Expo React Native application. The steps cover both iOS and Android platforms, focusing on projects that use expo prebuild or have been ejected, resulting in their own ios and android directories.

Note: This integration does not work with Expo Go, as Expo Go does not support custom native modules. You will need to build a standalone app using Expo's build services or build it locally.

Expo Setup

To install the SDK in your Expo app, you have two main options:

  1. Use Prebuild or Eject Your App: If your app uses expo prebuild or has been ejected, you can follow the platform-specific installation steps for each platform as detailed below.

  2. Use lucra-react-native-sdk expo plugin: To avoid manual customization of the native directories, you can adjust your app.config.js file and utilize the provided Expo plugins to handle the necessary configurations.

Using the Expo Build Properties Plugin

The expo-build-propertiesarrow-up-right plugin allows you to modify native build properties directly from your app.config.js. This is useful for setting deployment targets and specifying frameworks without touching the native code.

Update your app.config.js file with the following configuration to set the iOS deployment target and android minSDKVersion:

Using Custom Fonts

Follow the guidelines on installing expo-font plugin and configure it to load the fonts. This will make the fonts available on android and iOS.

For android just pass the path of each font relative to "fonts/"

For iOS pass the font's familiy name Note: The current iOS implementation will use the font's family name and search for Bold, Regular and SemiBold variations, please make sure to provide all of them to properly replace the font for each UI element.

Using Expo Dev Client

When working with expo-dev-client, it's essential to disable the EX_DEV_CLIENT_NETWORK_INSPECTOR variable, The SDK uses third-party libraries that block network inspection. To ensure that EX_DEV_CLIENT_NETWORK_INSPECTOR is turned off make sure networkInspector is false when using expo-build-properties.

Make sure to add the required Info.plist changes to the iOS section in order to support Venmo callback urls and deeplinks:

iOS

The minimum target version is iOS 15.1, so you will also have to update this on your project (You can do it in the XCode general tab) and in your podfile:

In your ios folder Podfile:

Add the following lines to the top of your Podfile to allow Cocoa Pods to find our native SDK dependency, check out the example Podfilearrow-up-right for a reference:

use_frameworks! linkage: :static

Flipper

If you are using Flipper. you will need to disable Flipper as it fails to link when using `use_frameworks!``:

Flipper has been removed in the latest React-Native versions, so this might not apply to your app.

New Arch

The package is compatible with the new arch. There is however one problem with embedded views on Android. They don't work because they are made with Android Compose, which is not supported by react-navigation/react-native-screensarrow-up-right. If you need embedded components for now you will have to stick to the old arch.

Add Lucra private pod repo

Run the following command to add the native SDK dependency locally that you added previously as a source in the Podfile

Permissions

The following keys will need to be set in Info.plist or the binary may be rejected and the app will crash.

Firebase

If using firebase some additional steps are required, start by following the general setup https://rnfirebase.io/

Make sure to enable firebase to use static frameworks editing your /ios/Podfile:

Android

Lucra Android Native SDK artifacts are privately hosted on https://github.com/Lucra-Sports/lucra-android.

You will need the personal access token (PAT) created above to pull these packages at build time.

See how to create personal access token

Place credentials on local machine and build server

Once a PAT is obtained, you will need to store them on your machine for building locally and in your system environment for build pipelines. The SDK will look for the gradle.properties first then fallback on the System.env property.

Set PAT for local Android development

Place the following lines either on your machine's (Linux/Mac) ~ .gradle/gradle.properties file (create one if it doesn't exist), or in your Android project's gradle.properties file. If you use your Android project's gradle.properties file, be sure to not check this into your repo.

Set PAT for Android CI/CD pipelines

In order to build the project on your pipelines, the system env variables should be set.

Both approaches work for local and build servers, but ~ .gradle/gradle.properties for local development and env: for build pipelines are the best ways to keep your PATs safe.

Provide GPR Access with GPR credentials

After GPR_USER and GPR_KEY are correctly fetched at build time, you'll then need to provide repository access for gradle to resolve the private artifacts at build time.

In your root Android project's build.gradle

Android Auth0 compliance (if not already using Auth0)

We use Auth0 for auth, if your app doesn't use it already, add the following to your app's default config.

Min API version

LucraSDK requires a minimum API version of 24, you will have to update your project to bump this:

Manifest Requirements

The following manifest permissions, features, receivers and services are required to use Lucra

Application Requirements

Lucra leverages Coilarrow-up-right to render images and SVGs. In your application class, provide the LucraCoilImageLoader

Firebase

You will need to add the firebase crashlytics plugin to your app's configuration.

First on your android/build.gradle file add the dependency to the buildscript:

Next edit your android/app/build.gradle file. At the top of the file apply the plugin:

Initialize the Lucra SDK

circle-info

API Key Update (Required)

Starting with React Native SDK 5.0.0+, Lucra SDK initialization requires a new apiKey.

Docs will be updated once this verison is available

What changed

  • A new apiKey is required during Lucra SDK initialization.

  • The previous apiKey + apiUrl initialization pattern is no longer supported.

  • Existing integrations on older SDK versions continue to function as-is.

Required action

  • Update your Lucra SDK initialization to pass the new apiKey at runtime.

  • Remove prior apiUrl reference.

Notes

  • The apiKey used prior to this version will not work once this latest version is adopted.

  • Please reach out to Lucra to obtain your new Sandbox and Production keys.

  • Backend API keys are unchanged.

Import the SDK from the @lucra-sports/lucra-react-native-sdk package, you must initialize the SDK with an API key and an environment before anything else. The initialization is a promise since communication with the backend is async and required on init.

Last updated