I'm using Xamarin Forms and I manage to send notifications to my applications in both iOS and Android using Firebase. I want to change the Badge icon every time a notification arrives, with the application in the background.
Similar to Twitter or Whatsapp.
How can I change the Badge of my application when my application is in the background?
I used MessagingCenter in Xamarin before. It is a publisher and subscriber event that you can use.
For Android I use ShortcutBadger https://github.com/leolin310148/ShortcutBadger
But it's up to the Phone's Launcher to decide if it will show the badge and for me it wont show on the Emulator but it does work on my phone.
As for iOS I haven't looked into this yet so if you find one please do tell.
Related
I want my app I build with Cordova and which runs on Android and ios to check my server for some data. I then want to use this data to update the badge at the phone homescreen. For this badge I use the plugin created by Katzer https://github.com/katzer/cordova-plugin-badge.
Now I believe the best way to achieve this is to generate an Ajax call to get the data from the server. Problem is that I want to do this specifically when the user is not actually using the app, preferably about once a day. Now I have found that it is possible to achieve this in the background using various plugins that create a background mode, but this is battery intensive and won't work if the user as stopped the app.
My question is what would be the best way to update my badge without the user having to open the app?
As you said, you need to use a background service OR if you use FCM (Firebase Messaging plugin), you can set the badge number while you are sending a notification.
So the best way would be to push to the device when something happens and change the badge number at that time. Then there is no need to do any Ajax call as you can use the data that was sent with the notification.
Also welcome to S.O.
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 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 want to show a Push Notification as a banner in my Cordova-based app. When the app is in background by default on Android 5.0.1 when a Push Notification is received it gets added to the notification area. But is there any way to show it as a banner like Facebook or Whatsapp notifications?
There is library you can use TSnackBar in this place
Actually this is modified SnackBar found in support-design. It comes from top you can make it look like iOS banner notification.
Hope this will look and feel the same.
For Lollipop and above read this
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..