react-native-genius-sdk
v1.0.6
Published
A react native package for GeniusSDK
Readme
react-native-genius-sdk
A react native package for GeniusSDK
Installation
npm install react-native-genius-sdkConfiguration
Android:
First of all go to your android folder and in there go to your project's build.gradle and in the repositories block add:
maven {
url=uri("https://jitpack.io")
}For deep links to be configured you need to first associate your website domain with your app and then add an intent filter in the app's AndroidManifest.xml:
<intent-filter android:autoVerify="true" >
<data android:host="your-apps-domain"
android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>(For development) To add local GeniusSDK add to build.gradle
implementation(project(":GeniusSDK"))and to the example project's settings.gradle:
include ':GeniusSDK'
project(':GeniusSDK').projectDir = new File('Path-To -> .../Projects/GeniusSDK/Android/TestProjectAndroid/GeniusSDK')iOS:
(For development) To add local GeniusSDKFramework add to react-native-genius-sdk.podspec:
s.dependency 'GeniusSDKFramework'and to example project's Podfile:
pod 'GeniusSDKFramework', :path => '../../../IOS/GeniusSDKFrameworkPod'Usage
To only use the install attribution and data extraction, add the following in App.tsx:
import geniusSdk from 'react-native-genius-sdk';
import React, { useEffect, useRef } from 'react';
// ...
const initialData = useRef<{ [key: string]: any }>({});
useEffect(() => {
const initializeSdk = async () => {
initialData.current = await geniusSdk.connect();
};
initializeSdk();
}, []);To use dynamic links aswell, add the following:
import geniusSdk from 'react-native-genius-sdk';
import React, { useEffect, useRef } from 'react';
// ...
const initialData = useRef<{ [key: string]: any }>({});
useEffect(() => {
const initializeSdk = async () => {
initialData.current = await geniusSdk.connect();
await geniusSdk.dynamicLinkInit((data) => {
console.log('Callback triggered');
console.log(data);
console.log(geniusSdk.dynamicLinkData);
});
// // Or request the dynamic link data directly on the lifecycle methods
// let data = await geniusSdk.getDynamicLinkData();
// console.log(data);
};
initializeSdk();
}, []);To log an event along with all data:
<Button
title="Send Event"
onPress={() => {
geniusSdk.logEvent(EVENT_NAME.CUSTOM('Custom Event'), { username: "bob" })
// geniusSdk.logEvent(EVENT_NAME.INSTALL, { username: "bob" })
}}
/>To add an event listener to listen to events invoked by the Genius:
useEffect(() => {
let eventListener = geniusSdk.addListener(GENIUS_EVENTS.FIRST_EVENT, (data) => {
console.log('Event triggered');
for (const key in data) {
console.log(`Key: ${key}, Value: ${data[key]}`);
}
});
return () => {
eventListener.remove();
};
}, []);License
MIT
Made with create-react-native-library
