Standard
Remote notifications allow your application to receive messages from Actito in real time, even when the app is not active. To enable this functionality, include the actito-web/push module in your project. This module provides all the components necessary to register the push subscription and handle incoming notifications. You may implement a custom user interface to present notifications. However, we recommend including the actito-web/push-ui module to take advantage of the managed notification UI, which simplifies implementation and ensures a consistent user experience.
Before getting started with this module, ensure that the following steps have been completed:
- You have successfully completed the Getting Started guide
- You have created and setup the [WebPush service] in your Actito app
Service Worker and Web Push Requirements
To enable your website to receive push notifications, a Service Worker file must be available at the root of your domain. The Service Worker is responsible for handling incoming notifications in the background, even when the web page is not actively open.
To simplify implementation, the Actito Web SDK provides a prebuilt Service Worker that manages incoming notifications automatically — no manual integration required.
Ensure this file is served at:
https://your-website/sw.js
If you integrate the Service Worker as part of your build process, you can import it directly from the package as shown below:
import 'actito-web/push/sw'
Alternatively, you may import it from the Actito CDN using the importScripts function. When doing so, make sure that the imported version matches the SDK version used in your project.
importScripts('https://cdn-mobile.actito.com/libs/web/v5/{{version}}/actito-push-sw.js')
Mismatched versions between your SDK and the Service Worker file may lead to unexpected behavior when handling push notifications.
For more information on Service Workers and their lifecycle, refer to the MDN Service Worker API documentation.
Requesting Permission
To enable remote notifications in your web application, you must first obtain the user’s consent before sending any notifications. Due to browser security policies, this permission request cannot occur automatically during page load. It must be initiated as a direct result of a user action, such as clicking a button or interacting with a prompt within your website.
There are two primary approaches for onboarding users to enable remote notifications: you can either use a managed experience configured by Actito Support, or implement the functionality manually within your application.
When your account is configured with a specific launch mode, the SDK will automatically display the appropriate user interface components based on that configuration. It will also handle the activation of remote notifications when conditions are met, ensuring a smooth and compliant onboarding experience.
To update your launch mode or adjust your website’s onboarding flow, you can change your settings in your Actito app.
If your configuration uses the managed onboarding UI, make sure to include the corresponding CSS file in your project:
import 'actito-web/push/push.css'
Alternatively, if you prefer to manually handle the remote notification onboarding process, your application is responsible for managing the user interface and permission workflow — including when and how users are prompted to enable notifications.
Enabling Remote Notifications
You can enable remote notifications through the Actito SDK:
import { enableRemoteNotifications } from 'actito-web/push';
await enableRemoteNotifications();
After enabling, the SDK will register the device for notifications with Actito.
You can check the user’s current enrollment and permission status using:
import { hasRemoteNotificationsEnabled, getAllowedUI } from 'actito-web/push';
// Check if the user has previously enabled remote notifications.
const enabled = hasRemoteNotificationsEnabled();
// Check if the device is allowed to receive remote notifications.
const allowedUI = getAllowedUI();
These checks can help you update your app’s UI to reflect the user’s notification status or guide them to re-enable permissions if needed.
Disabling Remote Notifications
If the user chooses to stop receiving notifications, you can disable them programmatically:
import { disableRemoteNotifications } from 'actito-web/push';
await disableRemoteNotifications();
This action unregisters the device from receiving further remote notifications. It is recommended to provide a clear opt-out option in your app’s settings to comply with privacy and consent requirements.