secrethero-react-native
v1.6.0
Published
SecretHero ReactNative SDK
Downloads
29
Readme
Secret Hero Setup
Description
Secret Hero is a sdk designed to add gaming functionalities into your application. This SDK empowers developers to integrate engaging gameplay experiences, including leaderboard tracking and coupon rewards, enhancing user engagement and retention within your app.
Installation
To integrate the SecretHero library into your project, add the following dependency as follows;
With React Native:
npm install secrethero-react-nativeArchitecture Support
This library supports both React Native's Old Architecture (Paper + Bridge) and New Architecture (Fabric + TurboModules) with automatic detection and backward compatibility.
- ✅ Old Architecture: Works with React Native < 0.68;
- Android; in
example/android/gradle.propertiessetnewArchEnabled=falseand gradle sync - iOS; run pod update as
export RCT_NEW_ARCH_ENABLED=0 && pod install
- Android; in
- ✅ New Architecture: Works with React Native >= 0.68;
- Android; in
example/android/gradle.propertiessetnewArchEnabled=falseand gradle sync - iOS; run pod update as
export RCT_NEW_ARCH_ENABLED=1 && pod install
- Android; in
Setup
Initialize Secret Hero
The initialize function within the SecretHero SDK is responsible for initializing the SDK with specific configuration settings and an listener to handle events and callbacks.
The SecretHeroConfig class is responsible for the configuration initializing the SecretHero SDK.
import SecretHero from 'secrethero-react-native';
SecretHero.initialize(secretHeroConfig, secretHeroListener);let secretHeroConfig: SecretHeroConfig = {
token: "your_token",
userId: "user_id",
country: "country",
language: "language",
iconImage: iconImage,
isLayoutLTR: isLayoutLTR,
displayName: "display_name",
theme: {
primaryColor: "#191D21",
secondaryColor: "#FFFFFF",
highlightColor: "#7B61FF",
buttonColor: "#92FFD7",
}
};token: A token required for authentication and interaction with the SecretHero SDK.userId: Represents the user ID associated with the SecretHero session.displayName: An display name for the user within the SecretHero environment.language: An optional string indicating the preferred language setting.country: An optional string indicating the preferred country setting.iconImage: An optional String representing the file path name of application image.isLayoutLTR: An optional boolean value indicating the layout direction.primaryColor: An integer value representing the primary color used in the sdk's interface or visual elements (text color).secondaryColor: An integer value representing the primary color used in the sdk's interface or visual elements (background color).highlightColor: An integer value representing the color used to highlight specific elements or actions within the sdk's interfacebuttonColor: An integer value specifying the color utilized for buttons or interactive elements within the sdk's interface
- The
SecretHeroEventListenerserves as a callback mechanism within the SecretHero SDK, providing methods to handle various events and responses during the SDK's lifecycle and operations.
let secretHeroListener: SecretHeroListener = {
onInitialized: () {
console.log(`onInitialized`);
},
onInitializeFailed: (errorMessage) {
console.log(`onInitializeFailed $errorMessage`);
},
onOpen: () {
console.log(`onOpen`);
},
onClose: () {
console.log(`onClose`);
},
onEvent: (event, extras) {
console.log(`onEvent $event`);
}
};onInitialized(): Invoked when the SecretHero SDK is successfully initialized.onInitializeFailed(errorMessage: String): Triggered upon initialization failure in the SecretHero SDKonClose(): Called when the SecretHero session is closed or terminatedonOpen(): Executed when the SecretHero session is opened or activatedonEvent(): The onEvent function is a callback that handles specific game events and their associated data. Event (String) represents the type of event that occurred. It can have one of the following values: "GAME_SUCCESS", "GAME_FAILED", "GAME_CLICKED", "COUPON_COPIED", "GAME_STARTED". ExtrasMap<string, string | null>a map containing additional details about the event. Possible keys include: "gameName", "gameDuration", "gameCoupon"
- The
release()function within the SecretHero serves the purpose of releasing and resetting configuration and listeners associated with the SecretHero. Need to be called onDestroy
