I'm currently developing an app that uses the new firebase cloud messaging system. Now I see the topic feature of FCM.
I created a topic "news" and want to add sub topics e.g "news/weather" or "news/politics".
Altogether there are about 20 subtopics.
Is this even possible with FCM and is this god practice?
I usually start my topics with a prefix and then the subtopic, separating them with a _.
So if I have a sub-topic per user (great for sending user-to-user messages) I end up with:
/topics/users_puf
/topics/users_forj9
There might be better ways, so I hope others will answer too.
Related
I'm working on a chat app message like whatsapp clone in android using firebase.
Right now the application can chat user to user.
My problem right now is the messages was no identifier that the other user see the messages of one another.
In order to make a solution I concat the userId and currentUserId so that it will be the unique message identifier since I'm using firebase-auth.
So my question right now is if this solution is somewhat ok? or any suggestions for message identifier for app chat?
This is some of my code in my ChatActivity for retrieving chat messages
mFirebaseDatabaseRef!!.child("messages").child(mFirebaseUser!!.uid+userId))
Here is saving the messages for every message I push both for user devices
mFirebaseDatabaseRef!!.child("messages")
.child(mCurrentUserId+userId)
.push()
.setValue(friendlyMessage)
mFirebaseDatabaseRef!!.child("messages")
.child(userId+mCurrentUserId)
.push()
.setValue(friendlyMessage)
Here is the sample generated format in firebase (It will both generate two unique coming from two userId's want to chat)
Thanks
So my question right now is if this solution is somewhat ok?
Yes it is. Since this solution works and help you get your job done, it ia a very good solution. You may wonder, is there a better one?
There is no better or perfect solution for how to identify the messages in your app. The best solution, is the solution that fits your needs and makes your job easier. And I personally don't think that can be a better solution than the one that you are comfortable with.
or any suggestions for message identifier for app chat?
Since it is a one to one chat application, the way you identify a "chat room" that contain messages it right, since it is very easy to query. You can simply attach a listener on fromUidtoUid or toUidfromUid reference, and that's it, you got all the messages of a conversation between two users.
I'm using Firebase Cloud Messaging to send data payload and display notification in my Android and iOS apps. I'm integrating this in my iOS app and I'm in front of a curious thing.
Short story:
My notification server only send data messages (I mean JSON messages containing "data" field and with no "notification" field). In my Android app this is not a problem because I receive the message even if my app is in background in my Service implementation and I manually build a notification that I display. But in iOS case, how can I receive message when my app is in background to do the same? I mean if I add a "notification" field to my request I see the notification pop on my screen (when app is in background) and I can get data (located in the "data" field) after a click when my app is in foreground.
But can I have data when my app is in the background to manually display a notification?
Important precision:
The content of the displayed notification should be built app side and not server side because the server doesn't have enough informations, this is why I can't send the "notification" field in my payload message.
Thanks
EDIT: I solve (in part) this problem using this link. Shortly, I enabled both Background fetch and Remote notifications under Background Modes (and added content_available : true in the payload). Then I can process data received in didReceiveRemoteNotification: But now it still one thing: how make it works when my app is killed?
EDIT 2: I found something that could be the thing : that. Modifying the payload of a remote notification implies to handle incoming notifications before there are displayed. I'll try.
EDIT 3: Firebase doesn't support the mutable-content key required to make my solution found at EDIT 2 working. Discussion about that is here. So... Any idea?
I do not think it is possible to trigger "stock" notification on iOS from code the same way you do on Android using NotificationBuilder.
The only option available is to use hybrid messages with both notification and data payloads.
Check their doc for more information on hybrid messages.
On 16/02/14, Firebase added compliance with the "mutable-content" key. So that solved my problem and, I think, many people's problems.
Personal thinking:
I consider that 6 months late for this feature is really too much. I hope that future releases'll be up to date with iOS (as well as Android) releases.
Can we send emails within android using firebase , i have tried several libraries like GmailBackground,BackgroundMail, custom method of Javax to send mail , but unable to send any email ,not even a simple one.
So I wonder if Firebase give such a feature , it would be great ?
Firebase Email Sending Blog post is showing empty is i think deleted , but why?
if you have any working source or tutorial to sent an email with attachment , it would be great , thanks
I've been researching this all day...
Option with third-party: SendGrid.com
There's actually a blog post by Tyson Bailey where he explains how he managed to get that done using SendGrid.com (monthly fee) here:
http://blog.onaclovtech.com/2014/07/emailster.html
It even includes the link to a Git he created upon it.
The solution in fact uses AngularJS as #Rexford mentioned in his comment.
Other options... None that I know for the moment, and am exactly researching upon a solution through GCP.
I can tell you they have been working since 2014 on something called "Triggers" that would allow triggering API actions from the database changes (which would helps lot), but seems to have been merged into Google Cloud Functions lately which is in Alpha by the time.
The good news is that as of a few days ago Firebase does now support sending emails... Obviously not from Android - that would be horrible - but from Firebase Fucntions - see here for an example.
Don't think Firebase support that yet..
You can use maligun service with this library for now. I have tested, it works.
https://github.com/sargue/mailgun
https://documentation.mailgun.com/en/latest/quickstart-sending.html#how-to-start-sending-email
I'm using firebase to send notifications to my app(iOS and Android).
I'm not keen on using the data fields to send my notifications because for iOS didReceiveRemoteNotification doesn't get called when user has force quit the app.
I've tried setting "sound" to all sorts of things including default and null but I'm not getting any sounds/vibrations on either devices.
Thanks.
There was just a minor issue. I was placing the sound in root of json payload. While, it had to be inside the notification object. Firebase should really have a number of example payloads in their documentation.
You can refer firebase document, table 2a
Should put sound filed into notification payload, then it should work
I have a scenario where I register users to the system and after they are logged in then I would like to create something like a field called messages(i.e. Facebook messaging system) so 2 users can communicate between each other. This is just an idea but I am trying to find some resources and documentation on line without any luck of how can I achieve this. Can someone give me some advice please on what tools I could use in order to make this idea work ?
I am not asking for source code or so, I just need some advice on how I could achieve this or any kind of references to similar projects would be much appreciated.
Thanks in advance.
This is a perfect use case for a cloud pub/sub messaging service like Pusher or Realtime.co
Check this chat examples on github for Android and iOS:
https://github.com/realtime-framework/MessagingAndroidChat
https://github.com/realtime-framework/MessagingSwiftChat
Note: I work for SightCall. :-)
We offer a platform for realtime communication on mobiles and browsers. While we are best known for WebRTC Video, we also have a realtime data facility that makes it easy to send text-messages between two logged-in endpoints.
We have a sample Android App that shows how to use the framework. You can get an API key for free for a trial.
https://github.com/sightcall/Communicator-for-Android
Of particular interest to you regarding sending/receiving text messages - notice the lines concerning the use of
rtcc.dataChannel().send(bytes, 0, uid);
This is where a text message is sent to a User named by their 'uid', and the method
#RtccEventListener
public void onDataChannelOutOfBandEvent(DataChannelOutOfBandEvent event)
This is where a text message is received as an event.