Closed choiman1559 closed 3 months ago
I am seeing a similar problem. Some of my message types are arriving okay, some are exhibiting the same error as above.
I'm getting the same problem with both registerToFCM
and subscribeToFCM
.
push-receiver
does not suffer from this problem.
Please let me know what other info I can provide to help diagnose the issue. Thanks!
I have not been able to receive any messages at all using this library. This is what I'm doing.
const authSecret = generateFcmAuthSecret();
const ecdh = createFcmECDH();
registerToFCM({
appID: '<my-app-id>',
ece: {
authSecret: authSecret,
publicKey: ecdh.getPublicKey()
},
firebase: {
apiKey: '<my-api-key>',
appID: '<my-app-id>',
projectID: '<my-project-id>'
},
vapidKey: '<my-vapid-key>'
})
.catch(() => { })
.then((registration) => {
client = new FcmClient({
acg: {
id: BigInt(registration.acg.id),
securityToken: BigInt(registration.acg.securityToken)
}
});
client.on("heartbeat", () => {
console.log("Heart")
})
client.on('message', (message) => {
console.log(message);
});
client.on('message-data', (data) => {
console.log(data);
});
client.on('close', () => {
console.log("Closed");
});
client.on('login', () => {
console.log("Logged in");
});
client.connect();
});
I only get 1 heartbeat and 1 login event after which I don't get anything. Can anyone help me? According to the docs, I should be receiving a heartbeat every 5 secs minimum.
Edit: Please ignore me: I started getting the messages after adding ece as follows:
client = new FcmClient({
acg: {
id: BigInt(registration.acg.id),
securityToken: BigInt(registration.acg.securityToken)
},
ece: {
authSecret: authSecret,
privateKey: ecdh.getPrivateKey()
}
});
Solved. The problem appears to occur when re-importing and registering credentials that were previously registered and stored in storage.
This was resolved by changing to issue a new credential each time the FCM service is run. https://github.com/choiman1559/electron-push-receiver/blob/master/src/index.js
I was already using a new credential each time so this doesn't resolve my issue. I'll create a new ticket for that.
Solved. The problem appears to occur when re-importing and registering credentials that were previously registered and stored in storage.
This was resolved by changing to issue a new credential each time the FCM service is run. https://github.com/choiman1559/electron-push-receiver/blob/master/src/index.js
This doesn't seem to be a problem. I have got it to work with the same credentials each time. I simply had to re-type the credentials to their original format to get it to work.
privateKey = new Uint8Array(dataFromStorage);
authSecret = new Uint8Array(dataFromStorage);
id = BigInt(dataFromStorage);
securityToken = BigInt(dataFromStorage);
I tried implementing FCM reception using this library. My implementation: https://github.com/choiman1559/electron-push-receiver
Generating & Getting token via
registerToFCM
is totally ok, Andlogin
,iq
,heartbeat
event appears normally after connectFcmClient
,However, when I send an FCM message I don't get to read the message with the following log:
And my FCM message is: