I am new to gcm api for android and have for some time now i have being working on an android app to allow chatting between two users of the app. The app is such that a chat can only be initiated when one user opts to contact the other user. But my confusion comes in the manner i would be able to create a chatroom for these two users and for the other user to be able receive messages. since i found out that each user must subscribe to a topic inorder to receive messages in that topic. Would i have to subscribe all users to all possible topics or what? that is my big question but it seems it would have so much overhead considering i have 1000+ users.
Please i need all the help i can get here. Thanks
Would i have to subscribe all users to all possible topics or what?
GCM topic messaging allows your app server to send a message to multiple devices that have opted in to a particular topic.
It is not a requirement but it can ease the work for the server to send messages. In this tutorial, you will see that they have created a chat like environment using GCM without using the topic function.
BUT consider the effects on your server like how will it behave on the potential load when you use the topic messaging, especially the the message will trigger an interaction from the user to the server.
Related
I've researched this topic for a little while, but I can't seem to get it. Apparently Google hasn't made an UI for this is what I understand. So here's the question.
I like to send cloud messages to my app users (100k+) occasionally. The users have an option to turn these notifications off which works fine if the app is in foreground.
But for background, Firebase does not give me any way of handling this. The message will always go to the tray even a user has disabled it inside the app. Understandably the notification never makes it to the app.
I've read responses from people that we should send such messages directly from our own servers. Yes, I've got my own servers and I do send a lot of messages to my users directly from the server. I maintain a database of all fcm codes.
But I'm wondering if there's a way of achieving this through the firebase console. It's nice to have all messages in once place e.g. ios and android. Google will also show us statistics which are also important in analysing which notifications are working better.
I've seen a possible answer here, How can I disable firebase notification on android client app, but it looks very unconventional.
Any help would be appreciated.
to disable notifications just must add
FirebaseMessaging.getInstance (). UnsubscribeFromTopic ("Topic_Name");
Note: these must be previously subscribed to the Topic
to enable notifications again use this
FirebaseMessaging.getInstance (). SubscribeToTopic ("Topic_Name");
I am trying to develop the Messenger App like Whatsapp using Firebase.
I'm already done the code for device to device notifications and now I am trying to send the notifications to specified group.
Please provide the example code for the Group Notifications.
There are a few ways to send messages to groups of users:
Send the message to a topic that all users subscribe to. This is the simplest scenario, since you don't need to keep a list of tokens. But you have less control over the actual people that receive the message, as anyone who knows a topic can subscribe to it.
Keep a list of device tokens for each group in your app server, and then send to each individual device in the group.
You can also use the previous version of the API to send to batches of up to 500 tokens at a time. This sort of multicast delivery is not yet possible in the new API.
For an example of this, see the documentation of Cloud Functions and the sample repo.
Send to a device group with the legacy API. I'd only recommend this approach if the devices are actually owned by one user, which is the case that device groups are meant for.
Try this link
Don't forget this line Authentication:
key=<Your_API_Key>
The word (key) is important
I am working on an app, which requires Android push notifications to be implemented.
I have decided to use Firebase Cloud Messaging directly; without using any other abstraction such as AWS SNS or Pusher.
I would like to avoid storing and managing device tokens in the backend, by using the following approach.
In the android app.
When the user logs into the android application, obtain device token but not send it to the server.
Subscribe to a topic that is based on a agreed convention, such that the topic is unique to that user.
On logout unsubscribe from the topic.
In the Server.
Whenever a situation arises to send a notification to particular user, send push notification to the topic, that is based on the convention.
I would like to know if this is a viable strategy to avoid managing device tokens ?
Case against using topics.
From the official docs.
Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices.
For example, users of a local weather forecasting app could opt in to a "severe weather alerts" topic and receive notifications of storms threatening specified areas. Users of a sports app could subscribe to automatic updates in live game scores for their favorite teams.
I see that topics are recommended, when multiple devices are to be notified. But I have decided to create a topic per user, this would mean most topics would end up getting subscribed by only one device; Is this approach ok ?
I see that topics are recommended, when multiple devices are to be notified
Yes, multiple devices that have something common to listen to, which is the topic. Topics are used for messages that could be received by the general clients since it is public -- i.e. anyone could subscribe and receive messages sent to it.
What is advised to use for multiple devices, but for the same user is to use Device Groups (see my answer here for tips on Managing Device Groups). However, if you don't mind the "topics being public" part, then your approach should be fine.
Yes, Here required device tokens if we want to send push notification whoever installed your app.
My research we can save device tokens in back end at first time installation of your app that is better according to my understanding so that we can easy to send push notification across all devices.
I read the documentation for FCM in Firebase website, looked into answers here for related questions and googled. All good, but as a newbie I am not sure what's best approach when it comes in choosing the XMPP server.
Is there anything that would limit one of the servers in the list blow when it comes to connecting to FCM? I have a list of servers here.
Should I choose one of the servers in this list for FCM if I need device to device notifications or is there any other choice. I need it for when a new message arrives in a chat app or similar cases when a ChildAdded or modified and the app is backgrounded or closed?
I cannot find any info on the XMPP servers and if Firebase has any recommendation. I would need all three iOS, Android, and Web app support.
I'm currently working on an application build on AWS. At first, the application was on Parse server and the push notifications were not a problem but then, when I migrated to AWS I encountered some issues with that.
As far as I read from this link http://aws.amazon.com/articles/9156883257507082 I learned that I need to create a topic to subscribe users by creating endpoints using the device tokens from where they are currently logged in.
I will have many users, and the notifications will be sent to all endpoints from a topic.
The problem is when I want to send a notification I want to exclude some users from a topic for receiving that, for example, when a user posts something I will not send a notification to him too. This is available also when I have a custom audience to send notifications to. I could create a topic for every event notification to be sent but I don't think this is a efficient method.
Is there a possibility to do that or Amazon does not even support this feature? Until now I didn't find anything on internet that can help me solve this problem and I hope I'll find here someone who worked with this.
Thank you for your time!
Plus : I also found a similar question here Send Push Notifications using Amazon SNS service but I still don't have a certain answer or some links about that.
From what I've found in AWS documentation, it states that
Send messages directly to a specific device by calling the Publish function with the device’s ARN. You can easily scale this to handle millions of users by storing the endpoint ARNs in Amazon DynamoDB and using multi-threaded code on the server.
Thus, to be able to filter users that receive notifications and not send bulk messages to all users subscribed to a topic, you need to send messages using the device's ARNs.
You can find more info here