web-push-libs / web-push

Web Push library for Node.js
Other
3.28k stars 306 forks source link

Got Status header 401 & errno 109 on KaiOS 2.5.1 device #603

Closed arma7x closed 4 years ago

arma7x commented 4 years ago

Setup

Operating System: Linux Node Version: v12.18.2 web-push Version: 3.4.4

Please select any browsers that you are experiencing problems with:

  • [ ] Chrome
  • [ ] Firefox
  • [x ] Other(KaiOS 2.5.1)

Please list the browsers you are have tested this, including the version

  • Chrome 84.0.4147.89 (Official Build) (64-bit)
  • Firefox 78.0.2 (64-bit)
  • KaiOS 2.5.1

Problem

Failing to receive push notifications on KaiOS 2.5.1 but am 100% successful when it comes to desktop chrome and desktop Firefox.

Expected

Expecting to receive push notifications on KaiOS 2.5.1.

Features Used

Example / Reproduce Case

require('dotenv').config({ path: 'variables.env' });

const express = require('express');
const webPush = require('web-push');
const bodyParser = require('body-parser');
const path = require('path');
const cors = require('cors')

const app = express();

app.use(cors())

app.use(cors())

app.use(bodyParser.json());

app.use(express.static(path.join(__dirname, 'client')));

const publicVapidKey = process.env.PUBLIC_VAPID_KEY;
const privateVapidKey = process.env.PRIVATE_VAPID_KEY;

webPush.setVapidDetails('mailto:test@example.com', publicVapidKey, privateVapidKey);

// Subscribe route

app.get('/subscribe', (req, res) => {
  const subscription = JSON.parse(decodeURI(req.query.body))
  //res.status(200).json(subscription);

  // create payload
  const payload = JSON.stringify({
    title: 'Push notifications with Service Workers',
  });

  setTimeout(() => {
    webPush.sendNotification(subscription, payload)
    .then((success) => {
      console.log(success);
      res.status(success.statusCode).json(success)
    })
    .catch((error) => {
      console.log(error);
      res.status(error.statusCode).json(error)
    });
  }, 3000);
});

app.set('port', process.env.PORT || 5000);
const server = app.listen(app.get('port'), () => {
  console.log(`Express running → PORT ${server.address().port}`);
});
arma7x commented 4 years ago

https://developer.kaiostech.com/core-developer-topics/using-push-notifications

arma7x commented 4 years ago

KaiOS push service use aesgcm instead of aes128gcm