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.
Related
I have seen some apps that take me into a web page and after reach certain endpoint the browser closes itself automatically then I continue in the original app.
Another app that takes me to my SMS messaging app then autofill the textbox and when I click send, again the same thing happens the SMS app closes itself and then continue in the original app, how can I get the results of those intents.
In both cases, the app returns with data received I think it's from the backend
Have a look at Android deeplinks
Basically you create some deeplink for your app like yourapp://awesomeintent and the website calls this link. In your AndroidManifest.xml you register some activity for this deeplink with the help of intent-filters and then your app pops up as soon as any other app/website opens your deeplink.
Keep in mind: If the user has more than 1 app which can process the deeplink, Android will ask him which app he wants to choose to do so.
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.
Using OneSignal Push Notification system, I send different links as notifications to my app users. But when a user clicks on the notification, it opens the "Complete action using.." app list.
Is it possible to open those links inside a WebView component of my app? I'm using MIT app inventor. (The action would be like when someone clicks a notification from Facebook, it shows the content inside the Facebook app.)
If you can't get this working in App Inventor, you might want to try Thunkable, which is based on App Inventor but adds additional functionality, such as One Signal based Push Notifications. Take a look at https://docs.thunkable.com/android/components/push-notifications.html
Hope this helps.
-Mark
I'm building an apache cordova messaging app (using javascript).
I'm looking for a way to have more control over notifications in my app.
Is there a way to receive a notification and build its text on the client device? I would like to create it in the user's proffered language and use the user's contacts names in the notification itself.
Also, I would like to be able to decide if to show a certain notification when it is received in the device (for example, don't show a notification for a group chat that was silenced)
Is it possible to do when the app is not open at all?
How is it handled differently from native android and iOS apps?
We are talking about push notifications right?
I don't remember the exact function names but think it's quite possible using cordova notification plugin.
So when app is in active/background, you will be able to get the notification object in your callback and decide whatever you do - show it in notification area using local notification, or show in-app alert or just ignore.
When app is closed, system handles the notification and shows in notification area(based on the notification payload APNS/GCMS sends) and when user taps on it, app is launched and a notification handler callback is called inside app.
Anyway, I think what you want to do is quite possible with native apps and cordova plugin since it exposes all of native functionalities.
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..