We are using devices which has Linux OS, javascript enabled (using node.js). We are using google FCM to receive notifications. We are using a javascript library (added register() here) to get the fcm token by passing sender ID. It was all working fine. But from past few days we are getting PHONE_REGISTRATION_ERROR and UNIMPLEMENTED error / UNIMPLEMENTED error when we are trying to get the FCM token.
Below is the code snippet.
(async () => {
try {
const credentials = await register(senderID);
const token = credentials.fcm.token;
const persistentIds = [];
await listen({ ...credentials, persistentIds }, onNotification);
} catch (e) {
console.log("Error::" + e);
}
})();
Below is the code for register function
const uuidv4 = require('uuid/v4');
const { register: registerGCM } = require('../gcm');
const registerFCM = require('../fcm');
module.exports = register;
async function register(senderId) {
// Should be unique by app - One GCM registration/token by app/appId
const appId = `wp:receiver.push.com#${uuidv4()}`;
const subscription = await registerGCM(appId);
const result = await registerFCM({
token : subscription.token,
senderId,
appId,
});
// Need to be saved by the client
return Object.assign({}, result, { gcm : subscription });
}
From past few days we are getting PHONE_REGISTRATION_ERROR and UNIMPLEMENTED error like below.
Register request has failed with Error=PHONE_REGISTRATION_ERROR
Retry... 1
Error::StatusCodeError: 501 - "{\n \"error\": {\n \"code\": 501,\n \"message\": \"Operation is not implemented, or supported, or enabled.\",\n \"status\": \"UNIMPLEMENTED\"\n }\n}\n"
Or some times UNIMPLEMENTED error alone and unable to get the token. I tried to restart the devices multiple times but of no use.
I went through lot of questions online. All are showing issues with Android apps where the solution is like to clear cache, remove app and reinstall app. But I couldn't find a solution for this javascript based program. Can someone please let me know if there is anyway to solve this issue.
The javascript library push-receiver is using legacy APIs of firebase. FB stopped supporting these APIs which is the reason for the failure. We changed our code to use push-receiver-v2 library which fixed the issue.