If you encounter connection errors such as 'connection refused' or a '401 Unauthorized' error when initializing the Pushwoosh Web Push SDK, it's often due to missing or Incorrect apiToken
. The Web SDK requires an apiToken
for authorization with the Pushwoosh backend.
Solution:
- Ensure the "Device API token" is enabled for your application in your Pushwoosh Control Panel. This setting is typically found under the API Access section for your specific application. More info: Device API token.
- Include the
apiToken
parameter along with your actual Device API token value in the SDK initialization script. For example:
Pushwoosh.push(['init', {
logLevel: 'debug', // or 'error', 'info', 'none'
applicationCode: 'YOUR_APPLICATION_CODE',
safariWebsitePushID: 'YOUR_SAFARI_WEBSITE_PUSH_ID', // If applicable for Safari
defaultNotificationTitle: 'My Default Title',
defaultNotificationImage: 'https://your-site.com/img/logo-192x192.png',
autoSubscribe: true,
subscribeWidget: {
enable: true
},
apiToken: 'YOUR_DEVICE_API_TOKEN' // <-- Add this line with your token
}]);
By verifying that your apiToken
is correctly configured and that your site meets the HTTPS requirement, you should be able to resolve these common connection errors.
Comments
0 comments
Article is closed for comments.