Back

Add target for push notification in web app

  • 0
  • Messaging
  • Web
  • Cloud
Fede_
27 Aug, 2024, 14:29

Hi, I tried looking for some similar problems but couldn't find any. Even with the doc I couldn't solve the problem.

Meanwhile, I use appwrite cloud with the latest sdk on a vue 3 js app.

I am developing a PWA and would like to set up sending notifications for various scenarios, to do this I set firebase FCM Messaging for notifications from firebase console and on my vue app.

Sending a test message actually gets received by the various clients.

Now I would like to move the handling of notifications to appwrite and to do this I set as the provider for push notifications, FCM with its congif.json file.

From here on I have various doubts: -Now do I need to add to the various users a target for notifications? if yes how can I do that? Using

TypeScript
messaging.createSubscriber?

In the doc I only saw examples for android or ios apps.

TL;DR
Developers are trying to add a target for push notification in a web app using Appwrite cloud and are encountering an 'Invalid `targetId` param' error due to UID constraints. The issue lies in the length of the UID. They are using the latest SDK on a Vue 3 app and wish to handle notifications through Appwrite instead of Firebase. They need to ensure the UID does not exceed 36 characters when creating a subscriber for notifications using `messaging.createSubscriber`.
Fede_
27 Aug, 2024, 14:35

As a test I tried to enroll an auth client with:

TypeScript
const result = await messaging.createSubscriber(
  '<topic_id>',
  ID.unique(),
  <token from firebase getToken()>
);

but i received

TypeScript
AppwriteException: Invalid `targetId` param: UID must contain at most 36 chars
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more