flourish_flutter_sdk 2.5.5
flourish_flutter_sdk: ^2.5.5 copied to clipboard
Flourish SDK for partners integrate.
Flourish SDK Flutter #
This flutter plugin 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 pubspec.yaml file, add the last version of Flourish Flutter SDK to your dependencies.
# pubspec.yaml
dependencies:
flourish_flutter_sdk: ^<latest version>
SDK internal requirements #
To use this SDK, you will need these elements:
- access_token: a string that represents a token that you will retrieve from our API
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 #
After adding our module, it is necessary to retrieve an access token from our API, and we strongly recommend that it be done through a backend because the request needs your credentials and it's good to avoid the harmful environment of the web.
Initialize the SDK providing the variables: token, env, language.
Flourish flourish = Flourish(
token: 'HERE_YOU_WILL_USE_THE_RETRIEVED_API_TOKEN',
env: Environment.staging,
language: Language.english
);
Finally we must call the home() method.
flourish.home();
There is a more elaborate example inside the sdk repository, you can access it by clicking here.
EVENTS #
You can also register for some events to know when something happens within our platform.
You can listen to a specific already mapped event, an unmapped event, or all events if you prefer.
Listen our mapped events #
We have some events already mapped that you can listen to separately
For example, if you need know when ou Trivia feature finished, you can listen to the "TriviaFinishedEvent"
flourish.onTriviaGameFinishedEvent((TriviaGameFinishedEvent response) {
print("Event name: ${response.name}");
print("Event data: ${jsonEncode(response.data.toJson())}");
});
you can find our all mapped events here: https://github.com/Flourish-savings/flourish-sdk-flutter/tree/main/lib/events/types
Listen our unmapped events #
Even if our platform starts sending new unmapped events, it will not be necessary to update the SDK version to consume them.
Just start listening to the generic events
flourish.onGenericEvent((GenericEvent response) {
print("Event name: ${response.name}");
print("Event data: ${jsonEncode(response.data.toJson())}");
});
Listen all events #
But if you want to listen all the events, we also have that for you.
flourish.onAllEvent((Event response) {
print("Event name: ${response.name}");
});
Events to listen #
here you have all events we will return
| Event name | Description |
|---|---|
| BACK_BUTTON_PRESSED | When you need to know when the user clicks on the back menu button on our platform. |
| TRIVIA_GAME_FINISHED | When you need to know when the user finishes a Trivia game on our platform. |
| TRIVIA_CLOSED | When you need to know when the user closed the Trivia game on our platform. |
| REFERRAL_COPY | When you need to know when the user copy the referral code to the clipboard area. |
| GIFT_CARD_COPY | When you need to know when the user copy the Gift code to the clipboard area. |
| HOME_BANNER_ACTION | When you need to know when the user clicks on the home banner. |
| MISSION_ACTION | When you need to know when the user clicks on a mission card |
| INVALID_TOKEN | When you need to know when then token expired. |
