how to set notificaton badge number when app background/closed in ios
See original GitHub issueit work perfectly when app foreground and not work when app background and closed. my code:
onNotification: (notification) => {
Device.detectNotification({"data_extra onNotification DEBUG DATA ":notification});
if(Platform.OS === "ios")
{
if(notification.message.notification_id){
if ( notification.foreground ){
// alertDropDown IOS
ios_noti_data = notification.message;
this.dropdown.alertWithType('custom', notification.message.title, notification.message.body);
}
}
}
// set badge number icon app
let notification_redux = store.getState();
if ( Platform.OS === 'ios' ){
PushNotificationIOS.setApplicationIconBadgeNumber(notification_redux.notification_badge+1)
}else{
RNBadgerAndroid.setBadge(notification_redux.notification_badge+1)
}
// count number natification unread to notification badge
setTimeout(()=> {
NotificationAPI.getNotificationUnRead()
},1000)
// process the notification
// Handle When User Tap on notification forceground Android
const clicked = notification.userInteraction;
if (clicked ) {
Device.detectNotification({"data_extra userInteraction ":notification});
let nofify_data;
if (Platform.OS === "ios"){
nofify_data = notification.message;
}else{
nofify_data = notification;
}
_handleNavigateScreenForSubUrl(nofify_data);
}
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Update badge with push notification while app in background
You have 2 ways of updating the badge count in the background. I've done this for my current app also. You don't need...
Read more >setting badge count when app is killed - Apple Developer
Hi, I have an app that receives push notification from server with "content-available": 1. and i have set my app to increase badge...
Read more >Troubleshooting the Badge Count - Things Support
On your iPhone or iPad, leave Things and go to the Settings app. · Tap Notifications. · Scroll down to find Things and...
Read more >Increment iOS app's badge count in using 5 simple steps.
Step 1: Add UNNotificationServiceExtension inside the app. · Step 2: Setup App Groups. · Step 3: Setup User suit for storing badge count....
Read more >iOS 15: How to Hide App Notification Badges on the Home ...
1. Open Control Center by swiping down diagonally from the top-right corner of the screen. 2. Tap the Focus button. 3. Tap the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok not obvious but eventually get to the bottom of it. look here https://github.com/zo0r/react-native-push-notification/blob/master/trouble-shooting.md you need to send silent or mixed notifications
Finally I managed to solve the problem/