Closed amilich closed 4 weeks ago
Hi @amilich , thanks for trying @aracna/fcm, you're forgetting the ece part inside the client, which is needed to decrypt the messages.
const authSecret = generateFcmAuthSecret()
const ecdh = createFcmECDH()
const res = await registerToFCM({
appID: ...
ece: {
authSecret: authSecret,
publicKey: ecdh.getPublicKey(),
},
firebase: {
apiKey: ...
appID: ...
projectID: ...
},
vapidKey: baseVapidKey,
})
client = new FcmClient({
acg: {
id: BigInt(res.acg.id),
securityToken: BigInt(res.acg.securityToken),
},
ece: {
authSecret: authSecret,
privateKey: ecdh.getPrivateKey(),
},
heartbeat: {
frequency: 500,
},
})
client.on("message", message => {
console.log("message")
console.log(message)
})
Let me know if adding that fixes your problem, thank you!
Reference in docs: FcmClient - Listen to messages
Hello, @alchemicas !
I do have my setup as in https://github.com/queelag/fcm/blob/main/examples/node/src/register-and-listen.ts
And I always get this error when I receive messages. However, I'm able to receive and process the message, so I ignored this, as it does not seem to affect functionality.
Hi @juangvega , thanks for using @aracna/fcm! Could you please open another issue for this? I might just lower the level of that log since warn is a bit too much.
Hi @amilich , thanks for trying @aracna/fcm, you're forgetting the ece part inside the client, which is needed to decrypt the messages.
const authSecret = generateFcmAuthSecret() const ecdh = createFcmECDH() const res = await registerToFCM({ appID: ... ece: { authSecret: authSecret, publicKey: ecdh.getPublicKey(), }, firebase: { apiKey: ... appID: ... projectID: ... }, vapidKey: baseVapidKey, }) client = new FcmClient({ acg: { id: BigInt(res.acg.id), securityToken: BigInt(res.acg.securityToken), }, ece: { authSecret: authSecret, privateKey: ecdh.getPrivateKey(), }, heartbeat: { frequency: 500, }, }) client.on("message", message => { console.log("message") console.log(message) })
Let me know if adding that fixes your problem, thank you!
Reference in docs: FcmClient - Listen to messages
got it - this worked! thank you. I can close this issue.
Seeing this error line:
I am able to log the buffer, but not sure how to decode it. I am running the code out of the box -
and this to send
any idea why? just want to get the test example working