Customer Engagement Platform for the Modern Data Stack
Castled React Native SDK enables React Native mobile applications running on iOS and Android devices to receive messages send from the Castled Customer Engagement Platform. It is implemented as a Turbo Native Module with backward compatability. Turbo Native Modules are the next iteration on React Native Modules for apps based on the New Architecture. This SDK facilitates:
- Receiving push notifications.
- Displaying in-app messages and app inbox notifications.
- Updating user profiles.
- Collecting user events.
The following steps will guide app developers on how to seamlessly integrate the SDK into their mobile applications.
Add the library to your project
npm install castled-react-native-sdk
-
Update
build.gradle
Include
google-services
plugin dependency in top-level gradle file// Top-level android/build.gradle file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { // Add google maven repository google() } ... dependencies { ... classpath("com.google.gms:google-services:<plugin-version>") } }
Apply
google-services
plugin to app gradle fileapply plugin: "com.google.gms.google-services"
-
Add required permissions
By default
AndroidManifest.xml
of the SDK includes the following permission requests. No developer action is required here.<!-- Castled SDK needs this permission to sync user token and campaign events --> <uses-permission android:name="android.permission.INTERNET"/> <!-- Castled SDK will use this permission to decide when to make network calls --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-
Pod Installation
Navigate to ios directory of your app project and run
pod install
Next step is to initialize the SDK. Initialization is typically done in App.js
.
import * as React from 'react';
// Importing SDK modules required for initialization
import {
CastledNotifications,
CastledConfigs,
CastledLocation,
} from 'castled-react-native-sdk';
import Header from './Header';
export default function App() {
...
React.useEffect(() => {
// Set config
const configs = new CastledConfigs();
configs.appId = '<app-id>';
configs.location = CastledLocation.US;
// Initialize SDK
CastledNotifications.initialize(configs);
}, []);
...
return (
<>
...
</>
);
}
api-key
is a unique key associated with your Castled account. It can be found in the Castled dashboard at Settings > Api Keys.location
is the region where you have your Castled account.
More details about the SDK integration can be found at https://docs.castled.io/developer-resources/sdk-integration/reactnative/getting-started
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library