firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.62k stars 367 forks source link

messaging/unknown-error when using sendEachForMulticast #2687

Closed davideicardi closed 2 weeks ago

davideicardi commented 2 weeks ago

I have a project that send notification messages to Android and IoS. We use sendEachForMulticast method. It worked fine for several months. But recently we started to receive the following error:

{
"code":"messaging/unknown-error"
"message":"Operation is not implemented, or supported, or enabled. Raw server response: "{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}""
}

We create the messages, using the MulticastMessage type, with the following structure:

{
      tokens: [token1, token2],
      data: {
         // ... (string->string)
      },
      android: {
        priority: 'normal',
        ttl: TTL_SECONDS * 1000,
      },
      fcmOptions: {
        analyticsLabel: 'my-label',
      },
      apns: {
        payload: {
          aps: {
            alert: {
              titleLocKey: 'key1',
              locKey: 'key2',
              locArgs: ['value1'],
            },
          },
          contentAvailable: true,
        },
        headers: {
          'apns-expiration': `${Math.floor(Date.now() / 1000) + TTL_SECONDS}`,
        },
      },
    };

Any ideas of what can be the problem? It could be related to https://firebase.google.com/docs/cloud-messaging/migrate-v1?authuser=0&hl=en ?

google-oss-bot commented 2 weeks ago

I found a few problems with this issue:

davideicardi commented 2 weeks ago

Sorry, my fault. I still used sendMulticast deprecated method.

quanndh commented 1 week ago

sendMulticast

hi what should we use instead?

davideicardi commented 1 week ago

sendEachForMulticast From the latest version of the lib

Sanjeevbadnur commented 3 days ago

Hi Team,

Issue : Facing inconsistent push notifications. With same token without any changes push notifications works for some times and does not works some times.

Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.4.0 Node.js version: Node.JS 20

Sample node code :

let message = {
  tokens: array of fcm tokens
  notification: 
    {
       title: "test_title",
       body: push notification message,
    },
  data: 
    {
       data: payload,
       alertType: "crash",
    },
};

let response = await firebaseAdmin.messaging().sendEachForMulticast(message);

The error message is random and either one of them

  1. {"success":false,"error":{"code":"messaging/mismatched-credential","message":"SenderId mismatch"}}

  2. {"success":false,"error":{"code":"messaging/unknown-error","message":"Operation is not implemented, or supported, or enabled. Raw server response: \"{\"error\":{\"code\":501,\"message\":\"Operation is not implemented, or supported, or enabled.\",\"status\":\"UNIMPLEMENTED\"}}\""}}

  3. {"success":false,"error":{"code":"messaging/registration-token-not-registered","message":"Requested entity was not found."}}

p29hieu commented 3 days ago

Hi Team,

Issue : Facing inconsistent push notifications. With same token without any changes push notifications works for some times and does not works some times.

Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.4.0 Node.js version: Node.JS 20

Sample node code :

let message = {
  tokens: array of fcm tokens
  notification: 
    {
       title: "test_title",
       body: push notification message,
    },
  data: 
    {
       data: payload,
       alertType: "crash",
    },
};

let response = await firebaseAdmin.messaging().sendEachForMulticast(message);

The error message is random and either one of them

  1. {"success":false,"error":{"code":"messaging/mismatched-credential","message":"SenderId mismatch"}}
  2. {"success":false,"error":{"code":"messaging/unknown-error","message":"Operation is not implemented, or supported, or enabled. Raw server response: "{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}""}}
  3. {"success":false,"error":{"code":"messaging/registration-token-not-registered","message":"Requested entity was not found."}}

Same Issue

levepic commented 2 days ago

Where is it stated that sendEach is deprecated? https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingsendeach Its still in the docu. Thanks for the answer I couldnt find out whats wrong since they secretely changed the method and the error response is misleading, also tests are misleading because for some of the requests they let it go through while randomly others get refused!:D

byeong1 commented 2 days ago

same issue

Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.2.0, Node.js version: Node.JS 20.12.1

use fn : sendAll()


Sometimes attempts with the same token will fail and sometimes they will succeed.


[ERROR]

[2024-09-12T04:43:08.339Z]  500   ERROR: (Error)Operation is not implemented, or supported, or enabled.
Raw server response:
"{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}"
gokul1630 commented 2 days ago

same issue

Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.2.0, Node.js version: Node.JS 20.12.1

use fn : sendAll()

Sometimes attempts with the same token will fail and sometimes they will succeed.

[ERROR]

[2024-09-12T04:43:08.339Z]  500   ERROR: (Error)Operation is not implemented, or supported, or enabled.
Raw server response:
"{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}"

try sendEachForMulticast https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendeachformulticast

byeong1 commented 1 day ago

same issue Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.2.0, Node.js version: Node.JS 20.12.1 use fn : sendAll() Sometimes attempts with the same token will fail and sometimes they will succeed. [ERROR]

[2024-09-12T04:43:08.339Z]  500   ERROR: (Error)Operation is not implemented, or supported, or enabled.
Raw server response:
"{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}"

try sendEachForMulticast https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendeachformulticast

nice!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

sawaYch commented 1 day ago

same issue Platform : Android and IOS Codebase : node.js Firebase-admin sdk version : 12.2.0, Node.js version: Node.JS 20.12.1 use fn : sendAll() Sometimes attempts with the same token will fail and sometimes they will succeed. [ERROR]

[2024-09-12T04:43:08.339Z]  500   ERROR: (Error)Operation is not implemented, or supported, or enabled.
Raw server response:
"{"error":{"code":501,"message":"Operation is not implemented, or supported, or enabled.","status":"UNIMPLEMENTED"}}"

try sendEachForMulticast https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging.md#messagingsendeachformulticast

Thanks u really save my day 😄 !! According to the change log, we may upgrade to >=11.7.0 https://firebase.google.com/support/release-notes/admin/node#cloud-messaging_2