Referral

Referral, These provide functionality to enable referral programs and sharing features in your application effortlessly.

Components Visuals

To unlock early access to the component Get Access

Installation

To install the Quest react-native-sdk into your project, follow these steps:

  • Open your terminal/command prompt.

  • Navigate to your project's root directory using the cd command if you're not already there.

  • Run the following command to install the quest-sdk package using npm:

npm install @questlabs/react-native-sdk

This command will download and install the package and its dependencies into your project.

Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

Usage

Root Component

  • Import the QuestProvider Component: Import the QuestProvider component from the @questlabs/react-sdk package.

import { QuestProvider } from '@questlabs/react-sdk';
  • Pass the Required Props: Pass the required props to the QuestProvider. The required props are apiKey, apiSecret, entityId and authenticationToken.

Component Usage

To integrate the useReferral component into your React native application, follow these steps.

  • Import useReferral Hook: Import the useReferral component from the @questlabs/react-sdk package.

  • Import the Referral Component: Import the Referral component from the @questlabs/react-sdk package.

  • Pass the Required Props: Pass the required props to the useReferral . The required props are questId, questUserId, and userToken or if user don't have quest User id then they can pass own userId to get questUserId and Token.

import { useReferral, Referral } from "@questlabs/react-native-sdk";

Don't not use QuestProvider and useReferral Hook in same file

Props of Referral Component

The Referral component accepts the following props

Props NameTypeRequire Details

header

string

Optional

Compoent Header Text.

descrption

string

Optional

Component Header Description Text.

referralLink

string

Require

referral link text

referralCode

string

Require

Referral Code Text.

primaryHeading

string

Optional

Title Text main view

primaryDescription

string

Optional

Description Text Main View.

shareButtonText

string

Optional

Send Button Text.

showRefferalLogo

boolean

Optional

To show the logo

loading

boolean

Optional

don't use in offline mode.

styleConfig

Object

Optional

An object containing Styling properties for styling various components within the get started process, including form, topbar, headings, descriptions, and buttons.

Style Prop

styleConfig {
  Form?: ViewStyle;
  Heading?: TextStyle;
  Description?: TextStyle;
  Input?: ViewStyle;
  Label?: TextStyle;
  PrimaryButton?: ViewStyle;
  Modal?: ViewStyle;
  Footer?: {
    FooterStyle?: ViewStyle;
    FooterText?: TextStyle;
    FooterIcon?: TextStyle;
  };
 
}

Example Usage

App.js

import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
import React, { useState } from "react";
import { QuestProvider } from "@questlabs/react-native-sdk";
import DemoComponent from "./DemoComponent";

export default function App() {
return (
    <SafeAreaView style={styles.container}>
      <StatusBar />
      <QuestProvider
        apiKey="Your-Api-Key"
        apiSecret="Your-Api-Secret"
        entityId="Your-Api-entityId"
        authenticationToken="Your-authentication-token"  >
        
        <DemoComponent />
        
        </QuestProvider>
   
    </SafeAreaView>
  );
}

DemoComponent.tsx

import React from "react";
import { Referral , useReferral} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
  // const referral = useReferral ({
  //   questId: "Your-Quest_ID" ,
  //   userId:"5235trfet365try67ywry5"
  //   })

  const referral= useReferral({
    questId: "Your-Quest_ID" ,
    questUserId: "Your-user-id",
    questToken: "Your-Token-id" 
    });
  return (
    <>
     <Referral 
        shareButtonText="Please share it"
        referralCode={referral.referralCode}
        referralLink={"https://www.questlabs.ai/"}
        loading={referral.loading}
        header={referral.title}
        descrption={referral.description}
        // primaryDescription="sgnanopgjnaohgoh"
        // primaryHeading=""
        showRefferalLogo={true}
        // styleConfig={{
        //   Description:{color:"yellow"},
        //   Footer:{
        //     FooterIcon:{color:"red"},
        //   },
        //   Form:{
        //     backgroundColor:"red"
        //   },
        //   Heading:{color:'orange'},
        //  Input:{backgroundColor:"lightgray"},
        //  Label:{color:"blue"},
        //  Modal:{backgroundColor:"gray"},
        //  PrimaryButton:{backgroundColor:"orange"}
        // }}
      />
    </>
  );
};
export default DemoComponent;

Demo

Last updated