2

I tried to test the firebase push notification with the stream-cli for my android device

On flutter mobile, i have connected my user and add the firebase messaging token to the StreamChatClient.

    await client.connectUser(
        User(
            id: userId, extraData: {'name': name, 'image': profile?.avatarUrl}),
        token,
      );
      log('connect chat user $userId');

      final firebaseMessagingToken =
          await FirebaseMessaging.instance.getToken();
      log('add user device to push notification service');
      if (firebaseMessagingToken != null) {
        log('firebase messaging token $firebaseMessagingToken');
        await client.addDevice(
            firebaseMessagingToken, PushProvider.firebase);
      }

After that, i try to test a push notif with the right userId (copied from the log in my flutter app) with the cli like below

stream-cli chat test-push --user-id dQIECWpyHbTaEsXmA1rp8e0ETyf2 --app epeak_production

but i got the following error Error: CheckPush failed with error: "User has no enabled devices associated"

Nicolas Bourdin
  • 323
  • 1
  • 3
  • 7

2 Answers2

2

From the user id you provided, I was able to check your data.

You created as multi bundle (probably via dashboard) but then added a device into non multi bundle config (through update app settings) which is disabled since there is no valid credentials on it. As a result, user doesn't have a valid device to send push notifications because it's linked to an invalid config.

If you create a config via dashboard, you provide a name to your config. While adding a device, you need to provide this name your call too so that it's connected to correct config (since there are many).

If you need more info, please contact support and feel free to share more sensitive information to check data state.

ferhatelmas
  • 3,818
  • 1
  • 21
  • 25
  • Thanks for your reponse ! It works <3 I don't understand what is the purpose of multi bundle, do you have the documentation page where it is explained please ? – Nicolas Bourdin Aug 29 '22 at 07:30
  • It has real benefits in some cases; you can find it here: https://getstream.io/chat/docs/react/push_providers_and_multi_bundle/?language=javascript – ferhatelmas Aug 31 '22 at 09:05
0

I had a similar issue in React Native. I had first registered the device without the named config (in my case for Firebase)

await chatClient.addDevice(
   newToken,
   'firebase',
   streamUserId,
   // wrong, missing named config
);

and even after I registered it with the named config it still was showing no devices for me in the dashboard (but it did show when I called chatClient.getDevices(streamUserId)!

What worked was calling remove device on all the existing devices, then registering fresh.

const devices = await chatClient.getDevices(streamUserId);
if (devices?.devices) {
  for (const device of devices.devices) {
     await chatClient.removeDevice(device.id, streamUserId);
  }
}
await chatClient.addDevice(
   token,
   'firebase',
   streamUserId,
   configName,
);
type
  • 366
  • 3
  • 8