Basic Usage
Median
notmedian
when using NPM packageWhen using the NPM Package make note to use capitalized
Median
to call functions rather than lowercasemedian
which is reserved for the the injected JavaScript library. Your IDE should be configured to help with code hinting to help with completion and avoid semantic errors.
import Median from "median-js-bridge";
import React, { useEffect } from "react";
const App: React.FC = () => {
useEffect(() => {
Median.onReady(() => {
window.alert("Median app ready!");
});
}, []);
}
OneSignal example demonstrating login and oneSignalId
retrieval
oneSignalId
retrievaluseEffect(() => {
Median.onReady(async () => {
const result = await Median.onesignal.login('test-user');
if (result?.success) {
const info = await Median.onesignal.info();
console.log(info?.oneSignalId);
// Do something with info?.oneSignalId such as store in database
}})
}, []);
JavaScript Bridge methods specific to NPM Package
โ๏ธMedian JavaScript Bridge
To check if running in your app:
Median.isNativeApp(); // Returns true or false
To retrieve the current platform:
Median.getPlatform(); // Returns a promise with a string web | android | ios
Updated 5 months ago
Next Steps