I've just implemented a notification feature on my RN project using RN firebase. I have sorted the parts where user clicks on notification and it triggers something in the app when it opens.
HOWEVER, I'm currently struggling to understand the flow of most apps out there where the case is like this:
User received and ignored the notification
User then later launch the app manually without tapping on the notification
Most apps I know, esp Instagram and Whatsapp would be able to still show in-app badges letting user know that they have new items incoming and highlight the newly received items
Now, I have successfully done the in app badges part in case user received the notification while app is in foreground, just like what Instagram and Whatsapp does.
But I just can't figure out how to identify, on app manual launch (not tapping on notification banner), if the user have some unopened notifications on the tray except by checking firebase.notifications().getBadge(). Problem with this, is that I wouldn't be able to know what do the new unopened notifications contain...
I have a feeling this is not something to be handled by notification module or firebase per se because this part has nothing to do with opening up a notification object on arrival.
Basically, I'm really not sure where to look right now. Any pointers would be highly appreciated :D
When a notification is delivered and the user did not open it, you need to store it somewhere and retrieve this data when the user opens the application without opening the notification.
For Android, you can use Shared Prefences and for iOS, you can use NSUserDefaults.
You can store the data as a stringified JSON. So when a user starts the applicatio, you can get the data from here and prepare your application according to these data.
If a user clicks on the notification or launches the app after getting your data, you should clear out this place to avoid data corruption.
Related
I'm currently developing an app for a client, and one of its requirements is to handle notification data from FCM. I read the FCM docs and to handle FCM data when the app is background/closed, I'm using the getIntent().getExtras() method.
However, this will only work if and only if the user taps the notification banner.
So, if the user ignores the notification banner and launches the app on the home screen, there is no way of getting the data from the system tray.
So, is there a way to get the data from the system tray without tapping the notification banner?
I tried investigating other android apps' behavior, like Gmail and Outlook, by sending an email while the apps are closed.
When a notification is prompted, I put my phone in airplane mode and launch the app without tapping the notification banner.
Somehow the app was able to get the email.
So is this data from the system tray's notification?
or a query from a server (I don't know if a post request from a server is possible since the app is in the background).
If anyone can explain or give a solution, it will be a big help for my project.
I'm currrently working with an android app that provides news, announcements and events updates.
Now I want to send notifications to all app users that there is a new announcement and when they click it they will go to announcement activity.
This is the announcement activity
This is I add announcement
What I want to achieve is, every time that the user (the one who create the announcement) click the button which is "Upload" it will trigger the app to send notification to all the users of my app. if possible I want it to be automatic no need to go to firebase but if it is impossible I'm okay with anything.
I just need an idea how to make it so I will follow but I would be so happy if someone could provide a sample code.
You should do this on the server side. The service that saves the announcement in the data base, can also send an FCM notification to a topic.
You can use the FCM HTTP V1 API to send notifications.
Is there any method to get App launch source(from home icon or other like notification bar etc.) in RN?
Or native way?
As far as I can think of there should be 3 different launch source for an app.
Home Icon
Notification
App Link
I don't think there is a direct way of knowing what is the source of launch but what you can do is to eliminate options one by one and end up the one which is used.
For example;
First you can check for if the app is opened with an app link. You can use Linking API for this.
getInitialURL()
If the app launch was triggered by an app link, it will give the link
url, otherwise it will give null
If the app did not launched with a link then you can check for notification data. There is lots of different libraries and techniques for using notifications with react-native and most of them has an event listener for notification data. You can check for any notification data and see if you are going to get any. React-native has PushNotificationIOS for native IOS notifications. Just to give you an idea you can use getDeliveredNotifications().
getDeliveredNotifications()
PushNotificationIOS.getDeliveredNotifications(callback);
Provides you with a list of the app’s notifications that are still
displayed in Notification Center
If both of these tries return with no information or data then app must be launched from home icon.
I'm developing a chat application like WhatsApp. We are using our own API with our own database server for sending and receiving messages. It is working perfect.
Now, the receiver and the sender should get the notification alert whenever they receive messages from each other if their apps is not opened.
It became a big task to me to accomplish. I'm unable to get the notification alert. I tried to use Firebase, but still I don't understand, what are requirements I need to give (Tokens, Keys).
Please, let me know if I need to change any data in my server side and is there any possibility to integrate from my server to Firebase and if it is possible then what are the parameters I need to integrate/send.
maintain status of each user , like when app opens make them online and onDestroy() make update status to offline , if user is offline send both message and notification where as if user is online send only message....
I am developing an android app and having a problem on the notification part of the app. I am planning to push a notification whenever a new announcement is recorded to the database even if the user does not run the application. The scenario is like having a notification when a facebook user adds you as a friend. Even the user did not open the facebook app, the application ,in the background, shows a notification that says someone added you as a friend. In my app I am going to show announcements whenever an announcement is added to the database. For me the problem is how to make my app to work in the background to check whether there is an announcement newly added to the database.
Thanks in advance.
You can be writing your app as an android service..