0

I am designing an application which has two types of user, vendor and Customer. Vendor delivers product and customers order them.

I want to send a notification when a Customer orders something from a vendor. Only that vendor should get notification. Similarly, when the product is mark delivered by vendor, a notification should appear on the customer side.

I was thinking of storing tokens in Firebase Database in the profile for each user, so let's say a customer orders something, he can retrieve Vendor's token so a notification appears on Vendor's side.

I recently came across this answer Cannot resolve symbol com.google.firebase.messaging.Message

which says it's not possible to do so, without admin SDK, which can't be used in Android App.

What options do I have for this use case?

Do I have to create my own server? Is there anyway to do this with just Firebase?

bejuzb
  • 55
  • 6
  • Does this answer your question? [How to send a firebase message to topic from Android](https://stackoverflow.com/questions/55948318/how-to-send-a-firebase-message-to-topic-from-android) – Mahmoud Abu Alheja May 29 '20 at 15:24
  • No, it is sending notification to a topic which are limited to 2000. So If I map one topic to user, number of users should not exceed 2000. Also as the comment says, only admin can send Notification that way. I need user to user notification – bejuzb May 30 '20 at 07:11
  • 1
    2000 limit is for One app instance not whole app, one app instance its mean every app on one device can subscribe to 2000 topics , show link here https://firebase.google.com/docs/cloud-messaging/android/topic-messaging – Mahmoud Abu Alheja May 30 '20 at 17:07

1 Answers1

0

I fell into this same problem before and I solved it by using a token which is the same as in my national number application through the topicKey when the employee sends to the user or I already created the topicKey for the user when he is in the process of registering in the application which is the national number.

When the employee accepts the user’s request, add the order number to the topicKey, which is the national number.

In your problem you can use the phone number because it is a unique code and create a topicKey based on it.

I hope I understood your problem correctly and I apologize for the spelling errors because it is not my native language.

Adel B-Lahlouh
  • 1,059
  • 1
  • 8
  • 20
  • 1
    If I understood correctly, you created a topic for every user. There are limits to number of topics that can be created for an app. 2000 topics per app I think. If the number of users exceed 2000, it will no longer work. – bejuzb May 27 '20 at 18:44