1.19.0 • Published 1 month ago

castled-react-native-sdk v1.19.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

npm version npm downloads min Android SDK version is 24 iOS 13.0+

Castled React Native SDK

:star: Introduction

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.

:roller_coaster: Getting Started

Installing SDK

Add the library to your project

npm install castled-react-native-sdk

Native Setup

Android

  1. 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 file

        apply plugin: "com.google.gms.google-services"
  2. 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"/>

iOS

  1. Pod Installation

    Navigate to ios directory of your app project and run pod install

Initializing SDK

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.

:books: Documentation

More details about the SDK integration can be found at https://docs.castled.io/developer-resources/sdk-integration/reactnative/getting-started

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.19.0

1 month ago

1.18.1

2 months ago

1.18.0

2 months ago

1.17.2

2 months ago

1.17.3

2 months ago

1.17.1

2 months ago

1.15.0

2 months ago

1.17.0

2 months ago

1.16.0

2 months ago

1.14.0

3 months ago

1.13.0

3 months ago

1.12.1

3 months ago

1.12.0

3 months ago

1.11.0

3 months ago

1.10.0

3 months ago

1.9.1

4 months ago

1.9.2

4 months ago

1.9.0

4 months ago

1.8.1

4 months ago

1.8.0

4 months ago

1.7.0

4 months ago

1.6.1

4 months ago

1.6.0

4 months ago

1.5.0

4 months ago

1.4.0

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.3.0

4 months ago

1.0.0

5 months ago

0.1.0

5 months ago