React Native SDK

This is a step by step guide to include Conscent.ai package in your app. This package is developed in TypeScript and JavaScript.

Installation
npm install csc-react-native-sdk
Initialize SDK

In your App.js file include ConscentWebView component in Stack.Navigator

import { ConscentWebView } from 'csc-react-native-sdk';

const App = () => {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="your_initial_route">
        ...
        <Stack.Screen name="ConscentWebView" component={ConscentWebView}
          options={{
            headerShown: false
          }} />
      </Stack.Navigator>
    </NavigationContainer>

  );
};
PARAMETERS
DISCRIPTION

yourClientId

Pass your clientId received from Conscent.ai

yourContentId

Unique id of each content

scroll-Y

Pass the scroll depth of your content screen

userAgent

Pass userAgent of your device

Mode

Mode can be set as :

STAGING

SANDBOX

LIVE

Initialize the paywall

Define these states on the content screen

    const [scrollY, setScrollY] = useState(0);
    const paywallRef = useRef(null);
    const [showPaywall, setShowPaywall] = useState(true);
    const [showContent, setShowContent] = useState(false);
    const [mode, setMode] = useState('SANDBOX');

Call the Paywall on top of your content screen

Paywall Listener

Implement the onStatusChange method in your component

  • METERBANNER: when receiving it then unlock content and show the paywall

  • PAYWALL: when receiving it then lock the content and show the paywall

  • UNLOCK: when receiving it then unlock the content and don't show the paywall

Login Functionality

The client can use his Login System using this functionality:

Generate token API is a post API that gets email, and phone number as a body parameter and generates an auto login token.

  • username: API Key gets from conscent dashboard

  • password: API Secret gets from conscent dashboard

  • getEnvDetails: call it to get the base URL of conscent api

Auto login uses webview to login users into ConsCent's system.

Check whether the User is login or not

Parameters to pass in autoLoginView

  • tempToken : Gets from generateTempToken api

  • clientId: Pass your clientId received from Conscent.ai.

  • email: Pass user email gets from your Google login

  • phone: Pass the phone number if you are signing in the user using the phone number

  • currentStackScreenName: Pass your current stack screen component name

  • navigation: Pass your navigation object to the current screen.

  • mode: Pass your environment mode

  • Mode can be set as : STAGING SANDBOX LIVE

Logout Functionality

Last updated