If the Pushwoosh web push subscription prompt (also called the 'consent widget' or 'opt-in prompt') isn't appearing on your website after you've added the integration code, these are the common technical reasons:
1. The initialization is missing the Device API token
Since Web SDK 3.x, apiToken is required. Without a valid Device API token the SDK cannot register the subscriber, so no prompt is shown. Create the token in the Pushwoosh Control Panel (Settings > API access, Device API token) and make sure it has access to the application you initialize with.
2. The service worker file is inaccessible or misplaced
- Pushwoosh needs
pushwoosh-service-worker.jsto handle push in the background. By default it must be served from the root of your site, e.g.https://your-website.com/pushwoosh-service-worker.js. - Check: open that URL directly. A 404 means the file is missing or in the wrong place.
- Fix: upload the file (from the Web platform configuration in the Control Panel) to the site root, or, if it has to live in a subdirectory, point the SDK at it with the
serviceWorkerUrlinit parameter.
3. Incorrect initialization syntax
The SDK is initialized through a global queue object named Pushwoosh. The stub declaration must be present and must use that exact name — renaming it to your own variable will break initialization.
Correct example:
<script src="//cdn.pushwoosh.com/webpush/v3/pushwoosh-web-notifications.js" async></script>
<script>
var Pushwoosh = Pushwoosh || [];
Pushwoosh.push(['init', {
logLevel: 'error', // or 'debug' for more logs
applicationCode: 'YOUR_APP_CODE',
apiToken: 'YOUR_DEVICE_API_TOKEN', // required
safariWebsitePushID: 'web.com.example.domain', // only if configured
defaultNotificationTitle: 'Your Website Title',
defaultNotificationImage: 'URL_TO_YOUR_DEFAULT_ICON',
serviceWorkerUrl: '/pushwoosh-service-worker.js', // change only if not in root
autoSubscribe: true
}]);
</script>
Incorrect (do NOT use) — the queue must be the global Pushwoosh object:
var myVar = myVar || [];
myVar.push(['init', { /* ... */ }]);
Troubleshooting tip: open the browser Developer Console (F12) and look for errors mentioning Pushwoosh, pushwoosh-service-worker.js, or an invalid/unauthorized API token when the page loads. Note that the prompt is only shown over HTTPS and only if the browser permission is still in the 'default' state.
Comments
0 comments
Article is closed for comments.