2.11.0 • Published 10 months ago

flourish-sdk-react-native v2.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Flourish React Native SDK

This React Native library will allow the communication between the visual implementation of Flourish functionality.

Table of contents

Getting Started


Adding Flourish to your project

In your project's package.json file, add the last version of Flourish Flutter SDK to your dependencies.

"dependencies": {
  "flourish-sdk-react-native": "*.*.*"
}

or install directly from terminal using npm or yarn

npm install flourish-sdk-react-native
yarn add flourish-sdk-react-native

SDK internal requirements

To use this SDK, you will need these elements:

  • partnerId: a unique identifier that will be provided by Flourish
  • secret: a string that represents a key, also provided by Flourish
  • language: a string that will represents witch language will be used (en, es, pt)

This plugin can be run in two different environments:

  • staging: In this environment, you can test the functionality without impacting any real data
  • production: this environment is for running the app with the real data

About the SDK

The integration with us works as follows, the client authenticates himself in our backend and we return an access token that allows him to load our webview, given that, the sdk serves to encapsulate and help in loading this webview.

Using the SDK


First foremost, it is necessary to initialize the SDK providing the variables: partnerId, secret, env, language and customer_code.

You can also pass a category this one isn't required.

  import { initialize } from 'flourish-sdk-react-native';

  const partnerId = process.env.PARTNER_ID;
  const partnerSecret = process.env.PARTNER_SECRET;
  const language = process.env.LANGUAGE;
  const environment = process.env.ENVIRONMENT;
  const customerCode = 'YOUR-CUSTOMER-CODE';
  const category = 'CATEGORY-VALUE';

  initialize(partnerId, partnerSecret, language, environment, customerCode, category);

WebView options

You can customize the webview component if you prefer, just initialize one of our configuration objects (WebViewOptions) and pass it in the initialization as the last parameter::

  import type { WebViewOptions } from 'src/components/
  CustomWebView';

  const webViewOptions: WebViewOptions = {
    androidLayerType: 'software',
    scalesPageToFit: true,
    domStorageEnabled: true,
    scrollEnabled: true,
    setBuiltInZoomControls: true,
    bounces: true,
    style: 'marginTop: 20',
  };

  initialize(partnerId, partnerSecret, language, environment, customerCode, category, webViewOptions);

Finally after initialization, you will be able to import and adding our Flourish component inside your screen, but remember that all our functionalities are displayed through a webview.

  import Flourish from 'flourish-sdk-react-native';

  return (
    <Flourish/>
  );

EVENTS


You can register for some events to know when something happens within our platform.

Listen all our events

To listen all our events, you will pass a generic callback function to our Flourish component when you add it to your screen.

import Flourish from 'flourish-sdk-react-native';

const genericEventCallback = (data: string): void => {
  console.log('Event Client side', data);
};

const RewardsScreen = () => {
  return <Flourish genericEventCallback={genericEventCallback} />;
};

Listen only to a specific event

To listen to only a specific event you will pass a function to an attribute referring to the event you want to listen to.

For example, if you want to be notified when a Trivia game ends, you can pass a callback function in the attribute called: "triviaGameFinishedEventCallback"

import Flourish from 'flourish-sdk-react-native';

const triviaGameFinishedEventCallback = (data: string): void => {
  console.log('Event Client side', data);
};

const RewardsScreen = () => {
  return (
    <Flourish
      triviaGameFinishedEventCallback={triviaGameFinishedEventCallback}
    />
  );
};

Events to listen

here you have all events we will return

Event nameDescription
BACK_BUTTON_PRESSEDWhen you need to know when the user clicks on the back menu button on our platform.
ERROR_BACK_BUTTON_PRESSEDWhen you need to know when the user clicks on the back menu button on our error page.
HOME_BACK_BUTTON_PRESSEDWhen you need to know when the user clicks on the back menu button when on the home screen of our platform.
ONBOARDING_BACK_BUTTON_PRESSEDWhen you need to know when the user clicks on the back menu button when on the onboarding screen of our platform.
TERMS_ACCEPTEDWhen you need to know when the user clicks to accept the terms.
TRIVIA_GAME_FINISHEDWhen you need to know when the user finishes a Trivia game on our platform.
TRIVIA_CLOSEDWhen you need to know when the user closed the Trivia game on our platform.
REFERRAL_COPYWhen you need to know when the user copy the referral code to the clipboard area.
REFERRAL_FINISHEDWhen you need to know when the referral finished.
REFERRAL_REWARD_REDEEMEDWhen you need to know when the user redeem the referral rewards.
REFERRAL_REWARD_SKIPPEDWhen you need to know when the user slipped the referral rewards.
GIFT_CARD_COPYWhen you need to know when the user copy the Gift code to the clipboard area.
HOME_BANNER_ACTIONWhen you need to know when the user clicks on the home banner.
MISSION_ACTIONWhen you need to know when the user clicks on a mission card
AUTHENTICATION_FAILUREWhen you need to know when the Authentication failed
ERRORWhen you need to know when a not mapped error happened.

Examples


Inside this repository, you have an example app to show how to integrate with us:

https://github.com/Flourish-savings/flourish-sdk-react-native/tree/main/example

2.11.0

10 months ago

2.10.1

10 months ago

2.10.0

10 months ago

2.8.0

12 months ago

2.9.0

11 months ago

2.6.3-candidate

1 year ago

2.6.3

1 year ago

2.7.0-candidate

1 year ago

2.7.0

1 year ago

2.6.4

1 year ago

2.6.2

1 year ago

2.6.2-candidate

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

2.5.0

1 year ago

2.4.1

1 year ago

2.4.0

1 year ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.2

2 years ago

2.1.1

2 years ago

2.0.0-17

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1-17

2 years ago

1.3.7

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.3.5

2 years ago

1.2.6

2 years ago

1.4.3

2 years ago

1.3.4

2 years ago

1.2.5

2 years ago

1.4.2

2 years ago

1.3.3

2 years ago

1.2.4

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.3.2

2 years ago

1.2.3

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.2.1

2 years ago

0.1.0

2 years ago