...
appAlias
value should be sent differently for iOS and Android apps (excluding Expo apps)
Example;
const appAlias = Platform.OS === "ios" ? "RelatedStoreIOS" : "RelatedStoreAndroid";
Don't forget to ask the RMC team for your alias, SID, OID and datasource values.
Code Block | ||
---|---|---|
| ||
import {
addEventListener,
removeEventListener,
requestPermissions,
EuroMessageApi
} from 'react-native-related-digital'
const appAlias = 'alias' // Get it from RMC team
export const euroMessageApi = new EuroMessageApi(appAlias);
export const AddEventListener = addEventListener;
export const RequestPermissions = requestPermissions; |
Useage
Note |
---|
You can review the lines about If you are not using Visilabs, remove lines 9, 22, and 36. |
Code Block | ||
---|---|---|
| ||
import import React, { useState, useEffect } from 'react'; import { SafeAreaView, StyleSheet, ScrollView, Button, View, ActivityIndicator, Platform } from 'react-native'; import { addEventListener, removeEventListener, VisilabsApi requestPermissions, EuroMessageApi, } from VisilabsApi } from 'react-native-related-digital' const App = () => { const [loading, setLoading] = useState(false) const appAlias = 'alias' const siteId = "SID"; const organizationId = "OID"; const dataSource = "datasource"; const euroMessageApi = new EuroMessageApi(appAlias) const visilabsApi = new VisilabsApi(appAlias, siteId, organizationId, dataSource) useEffect(() => { addExtra() addListeners() return () => removeListeners() }, []) const euroMessageApi = new EuroMessageApi(appAlias) |
Event Submission
A sample category page display event. All Visilabs events are sent with a function named customEvent
. The parameters that this function takes are performed event name and data.
Event Name : They are event names defined by Visilabs. Here you can find information about which name will come in which event. In this example the event name is Category View.
Data : It is the information sent next to the relevant event. Values are sent to certain parameter names according to the operation performed. The parameters are OM. gets the prefix.
Code Block |
---|
var data = {
"OM.clist": 123
};
visilabsApi.customEvent("Category View", data); |
...
addListeners = () => {
addEventListener('register', async (token) => {
const subscribeResult = await euroMessageApi.subscribe(token)
visilabsApi.register(token, (result) => {
})
}, (notificationPayload) => {
console.log('notification payload', notificationPayload)
}, euroMessageApi)
addEventListener('registrationError', async (registrationError) => {
console.log('registrationError is ', registrationError)
}, euroMessageApi)
}
const addExtra = async () => {
await euroMessageApi.setUserProperty('extra', 1)
}
const removeListeners = () => {
removeEventListener('register')
removeEventListener('registrationError')
}
return (
<>
<SafeAreaView>
{
loading ?
<ActivityIndicator
size='large'
animating={loading} /> :
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Button
title='REQUEST PERMISSONS'
onPress={() => {
requestPermissions()
}}
/>
</ScrollView>
}
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: '#FFF',
padding: 20
},
divider: {
height: 20
}
});
export default App; |
Ui button | ||||||
---|---|---|---|---|---|---|
|