A correct Web Push SDK integration is crucial for subscribing users to notifications. Two common areas to check are the initialization script parameters and the subscription prompt strategy.
1. Verify Your Initialization Script
Ensure your Pushwoosh.push(["init", {...}]) script includes all the required parameters. A common reason for integration failure is a missing apiToken. The apiToken is your Device API access token, which is required for the SDK to function correctly.
Here is an example of a correctly configured initialization script:
var Pushwoosh = Pushwoosh || [];
Pushwoosh.push(["init", {
logLevel: 'error',
applicationCode: 'YOUR_PUSHWOOSH_APP_CODE',
apiToken: 'YOUR_PUSHWOOSH_API_TOKEN', // Make sure this is included
safariWebsitePushID: 'YOUR_SAFARI_WEBSITE_PUSH_ID',
defaultNotificationTitle: 'Your Website Title',
defaultNotificationImage: 'https://yoursite.com/logo.png',
autoSubscribe: false, // Recommended setting, see below
serviceWorkerUrl: "/pushwoosh-service-worker.js",
}]);
2. Use the Best Practice for Subscription Prompts
While setting autoSubscribe: true will show the browser's native subscription prompt immediately on page load, this is not recommended.
Why avoid showing the system prompt immediately?
* Permanent Blocks: If a user declines the native browser prompt, they may be blocked from seeing it again on your site, making it very difficult to subscribe them later.
* Browser Suppression: Browsers like Chrome may automatically hide the prompt for users who frequently decline push notifications, significantly reducing your potential subscriber base.
Recommended Approach: The best practice is to use a two-step subscription process:
1. First, show a custom prompt or widget (e.g., a slide-in, a bell icon) to explain the value of your notifications and ask for permission.
2. Only when the user clicks "Allow" or "Subscribe" on your custom prompt should you then trigger the native browser prompt.
This approach ensures that you only show the critical system prompt to users who are already interested, leading to higher subscription rates.
For more details on implementing different types of subscription prompts, please refer to our Subscription Prompt documentation.
Comments
0 comments
Please sign in to leave a comment.