When integrating the Pushwoosh Web SDK using the NPM package, the subscription widget (PWSubscribePopupWidget) is not initialized automatically by default. You must explicitly import and run the widget after the main SDK initialization.
Two details matter, and both are common sources of a silently missing widget:
- The package name is
web-push-notifications. - Widgets are shipped as subpath entry points. The root import exposes only
Pushwoosh, soPWSubscribePopupWidgetmust be imported fromweb-push-notifications/widget-subscribe-popup.
Add the following after your init call:
import { Pushwoosh } from 'web-push-notifications';
import { PWSubscribePopupWidget } from 'web-push-notifications/widget-subscribe-popup';
const pushwoosh = new Pushwoosh();
// ... main SDK initialization code (pushwoosh.push(['init', { ... }])) ...
pushwoosh.push(async () => {
try {
const widget = new PWSubscribePopupWidget(pushwoosh);
await widget.run();
} catch (error) {
console.error('PWSubscribePopupWidget initialization failed:', error);
}
});This ensures the custom subscription prompt is triggered correctly. If the import path is wrong the build either fails to resolve the module or PWSubscribePopupWidget arrives as undefined, and no widget is rendered.
Comments
0 comments
Please sign in to leave a comment.