Notification Functions API
Manage notification actions using the WebToNative JavaScript API. Functions to register the app for push notifications and to clear notifications from the device's notification tray.
You'll need to import the javascript file in your website before starting from this link.
Register Notification
Registers the app for push notifications and returns the user's permission status along with the OneSignal player ID and Firebase token.
window.WTN.registerNotification({
callback: function (response) {
console.log(response.permissionStatus);
console.log(response.oneSignalPlayerId);
console.log(response.firebaseToken);
},
});import { registerNotification } from "webtonative";
registerNotification({
callback: (response) => {
console.log(response.permissionStatus);
console.log(response.oneSignalPlayerId);
console.log(response.firebaseToken);
},
});Parameters:
callback
Function
No
Callback function invoked with the response.
Callback Response:
type
String
Always "registerNotification".
permissionStatus
String
The notification permission status: "ALLOWED" or "NOT_ALLOWED".
oneSignalPlayerId
String
The OneSignal player ID for this device.
firebaseToken
String
The Firebase Cloud Messaging token for this device.
Remove All Notifications
Removes all currently displayed push notifications for the app from the device's notification tray/center.
Parameters:
callback
Function
No
Callback function invoked with the response.
Callback Response:
type
String
Always "removeAllNotifications".
isSuccess
Boolean
true if all notifications were removed successfully, false otherwise.
error
String or null
null on success. Error message describing what went wrong on failure.
Example:
Last updated