Type Reference

AppUserConfig

This object enables you to configure our SDK in various ways to suit your needs when calling OneSignal.init.

ParameterTypeDescription
appIdstringYour OneSignal App ID. You can find this on your app's settings page.
autoRegisterboolean | undefinedDeprecating: Shows Native Browser Prompt immediately. We do not recommend using because it creates a poor user experience.
autoResubscribeboolean | undefinedAutomatically resubscribes users when they clear browser cache or migrating to OneSignal.

You can configure this in the OneSignal dashboard during setup; however, if you set this during initialization, the dashboard configuration will be overridden.

We recommend that you only use this setting if your site is secured using HTTPS.
pathstring | undefinedProvide the absolute path to the service file if you stored the OneSignal Service Worker in a non-standard path.

Your site must be secured with HTTPS to set a custom path for the OneSignal Service Worker.
serviceWorkerPathstring | undefined
serviceWorkerParamany
subdomainNamestring | undefined<What is it for though?>

This must match the label you entered in Site Settings.

Your site must be secured with HTTPS to make use of this property.
promptOptionsAppUserConfigPromptOptions | undefinedConfigure the popup prompt.
welcomeNotificationAppUserConfigWelcomeNotification | undefinedCustomize or disable the welcome notification sent to new site visitors.
notifyButtonAppUserConfigNotifyButton | undefinedEnable and customize the Notify Button.
persistNotificationboolean | undefinedChrome (non-mobile) - true: persists notification, false: disappears after some time. See our Notification Persistence Section for more info.

Firefox and Safari - notifications automatically dismiss after some time and this parameter does not control that.
webhooksAppUserConfigWebhooks | undefined<What is this for?>
notificationClickHandlerMatchNotificationClickMatchBehavior | undefinedDefault: If the launch URL of the notification matches exactly to a tab already open it will be focused.

"origin"- If the launch URL of the notification matches any tab already open to your domain it will be focused.
notificationClickHandlerActionNotificationClickActionBehavior | undefined"navigate" Default: Automatically navigate to the launchURL on opening the notification.

"focus" - Only apply if notificationClickHandlerMatch is set to "origin". Only focuses an existing tab if the launch URL matches the domain instead of navigating.
allowLocalhostAsSecureOriginboolean | undefined
requiresUserPrivacyConsentBooleanAllows you to delay the initialization of the SDK until the user provides privacy consent. The SDK will not be fully initialized until the provideUserConsent function is called.
pageUrlstring | undefined
outcomesOutcomesConfig | undefined

AppUserConfigPromptOptions

Pass in these optional parameters within promptOptions when initializing to localize the prompts to your custom text and language. All entries are limited in length. Foreign characters accepted. Each parameter is optional, and its default is used when it is not included.

ParameterTypeDescription
actionMessageStringText that says 'wants to show notifications' by default. Limited to 90 characters.
exampleNotificationTitleDesktopStringText that says 'This is an example notification'. Displays on non-mobile devices. Only one line is allowed.
exampleNotificationMessageDesktopStringText that says 'Notifications will appear on your desktop'. Displays on non-mobile devices. Only one line is allowed.
exampleNotificationTitleMobileStringText that says 'This is an example notification'. Displays on mobile devices with limited screen width. Only one line is allowed.
exampleNotificationMessageMobileStringText that says 'Notifications will appear on your device'. Displays on mobile devices with limited screen width. Only one line is allowed.
exampleNotificationCaptionStringText that says '(you can unsubscribe anytime)'.
acceptButton - Slide Prompt

acceptButtonText - HTTP PopUp Prompt
StringCustomize the "Continue" text.
Limited to 15 characters.
cancelButton - Slide Prompt

cancelButtonText - HTTP PopUp Prompt
StringCustomize the "Cancel" text.
Limited to 15 characters.
showCreditBooleanSet to false to hide the OneSignal logo.

AppUserConfigWelcomeNotification

Pass in these optional parameters within welcomeNotification when initializing to customize or disable the welcome notification sent to new site visitors. Any person visiting your site for their first time, or an existing user who has completely cleared their cache is considered a new site visitor.

ParameterTypeDescription
disableBooleanDisables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
titleStringThe welcome notification's title. You can localize this to your own language. If not set, or left blank, the site's title will be used. Set to one space ' ' to clear the title, although this is not recommended.
messageStringRequired: The welcome notification's message. You can localize this to your own language. A message is required. If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
urlURLAn optional URL to open after the user clicks the welcome notification.

By default, clicking the welcome notification does not open any link. This is recommended because the user has just visited your site and subscribed.

AppUserConfigNotifyButton

Pass in these optional parameters within notifyButton when initializing to enable and customize the Subscription Bell (formerly known as the notify button). All parameters below are optional. If not set, they will be replaced with their defaults.

ParameterTypeDescription
enableBooleanEnable the Subscription Bell. The Subscription Bell is otherwise disabled by default.
displayPredicateFunctionA function you define that returns true to show the Subscription Bell, or false to hide it. You can also return a Promise that resolves to true or false for awaiting asynchronous operations.

Typically used the hide the Subscription Bell after the user is subscribed.

This function is not re-evaluated on every state change; this function is only evaluated once when the Subscription Bell begins to show.

See Hiding the Subscription Bell for an example.
sizeStringOne of 'small', 'medium', or 'large'. The Subscription Bell will initially appear at one of these sizes, and then shrink down to size 'small' after the user subscribes.
positionStringEither 'bottom-left' or 'bottom-right'. The Subscription Bell will be fixed at this location on your page.
offsetJSONSpecify CSS-valid pixel offsets using bottom, left, and right.
prenotifyBooleanIf true, the Subscription Bell will display an icon that there is 1 unread message. When hovering over the Subscription Bell, the user will see custom text set by message.prenotify.
showCreditBooleanSet false to hide the 'Powered by OneSignal' text in the Subscription Bell dialog popup.
textJSONCustomize the Subscription Bell text. See the example code below to know what to change.

AutoPromptOptions