React Native Package for linkrunner.io
rn-linkrunner also uses react-native-device-info
. You can install this package with the following command:
npm install react-native-device-info
or
yarn add react-native-device-info
Then run cd ios && pod install
to install pods for the package.
npm install rn-linkrunner
or
yarn add rn-linkrunner
You'll need your project token to initialise the package. Place this initialization step in your App.tsx
component, making sure the dependency array is empty for the useEffect
:
import linkrunner from 'rn-linkrunner';
// Inside your react component
useEffect(() => {
init();
}, []);
const init = async () => {
const initData = await linkrunner.init('PROJECT_TOKEN');
};
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
}
Call this function once your onboarding is completed and the navigation stack can be accessed by a deeplink:
import linkrunner from 'rn-linkrunner';
const onTrigger = async () => {
const trigger = await linkrunner.trigger({
user_data: {
id: '1',
name: 'John Doe', // optional
phone: '9583849238', // optional
email: 'support@linkrunner.io', //optional
},
data: {}, // Any other data you might need
});
};
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
trigger: boolean // Deeplink won't be triggered if false
}
Note: Value of trigger
will be only true for the first time the function is triggered by the user in order to prevent unnecessary redirects
Mail us on support@linkrunner.io
MIT