Usage with Listeners
Using the npm package allows you to utilize listener functions which are invoked when an event occurs. These are similar to on-page JavaScript callback functions but are easier to implement.
Add listener
Register listener, function will be called when the corresponding event is triggered.
App Resumed Event
const listenerId = Median.appResumed.addListener(() => {
console.log("App resumed listener");
});
OneSignal plugin
const listenerId = Median.oneSignalPushOpened.addListener((data) => {
console.log(JSON.stringify(data));
});
Share into app plugin
const listenerId = Median.shareToApp.addListener((data) => {
console.log(data.url, data.subject);
});
Haptics plugin
const listenerId = Median.deviceShake.addListener(() => {
console.log("Device shake listener");
});
AppsFlyer plugin
const listenerId = Median.appsFlyerConversionData.addListener((conversionDataMap) => {
console.log(conversionDataMap.af_status);
});
Remove listener
Remove a specific listener so that it will no longer be called when the corresponding event is triggered
Median.deviceShake.removeListener(listenerId);
Updated about 2 months ago