@ehrocks/react-native-superapp-communication
Utilities for communication between mini apps or mini app and core EH app
Installation
Open a Terminal in your project's folder and run,
yarn add @ehrocks/react-native-superapp-communication
Usage
Identity
User login event
import { Identity } from '@ehrocks/react-native-superapp-communication';
const removeLoginListener = Identity.addLoginListener((token) => {
console.log({ token });
});
Identity.dispatchLoginEvent('token');
removeLoginListener();
Token changed event
import { Identity } from '@ehrocks/react-native-superapp-communication';
const removeTokenChangedListener = Identity.addTokenChangedListener((token) => {
console.log({ token });
});
Identity.dispatchTokenChangedEvent('token');
removeTokenChangedListener();
User logout event
import { Identity } from '@ehrocks/react-native-superapp-communication';
const removeLogoutListener = Identity.addLogoutListener(() => {
console.log('Receive Logout event');
});
Identity.dispatchLogoutEvent({});
removeLogoutListener();
Notification
Open event
import { NotificationEvent } from '@ehrocks/react-native-superapp-communication';
const removeOpenNotificationListener = NotificationEvent.addOpenNotificationListener((payload) => {
console.log(payload);
});
const payload = {
type: 'notification_type',
organisation_id: '1234',
meta: {
appName: 'swagApp'
}
}
NotificationEvent.dispatchOpenNotificationEvent(payload);
removeOpenNotificationListener()
DeepLink
Open event
import { DeepLinkEvent } from '@ehrocks/react-native-superapp-communication';
const removeOpenDeelinkListener = DeepLinkEvent.addOpenDeepLinkListener((payload) => {
console.log(payload);
});
const payload = {
url: 'employmenthero://test',
}
DeepLinkEvent.dispatchOpenDeepLinkEvent(payload);
removeOpenDeeplinkListener();