MM-13897 preserve iOS push notifications when opening the app and set the proper badge count (#2541)
This commit is contained in:
parent
409d36d375
commit
2f997f631a
4 changed files with 10 additions and 6 deletions
|
|
@ -152,6 +152,8 @@ class PushNotification {
|
|||
clearChannelNotifications(channelId) {
|
||||
NotificationsIOS.getDeliveredNotifications((notifications) => {
|
||||
const ids = [];
|
||||
let badgeCount = notifications.length;
|
||||
|
||||
for (let i = 0; i < notifications.length; i++) {
|
||||
const notification = notifications[i];
|
||||
|
||||
|
|
@ -161,8 +163,11 @@ class PushNotification {
|
|||
}
|
||||
|
||||
if (ids.length) {
|
||||
badgeCount -= ids.length;
|
||||
NotificationsIOS.removeDeliveredNotifications(ids);
|
||||
}
|
||||
|
||||
this.setApplicationIconBadgeNumber(badgeCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ export default class Channel extends PureComponent {
|
|||
} else {
|
||||
this.props.actions.selectDefaultTeam();
|
||||
}
|
||||
|
||||
if (this.props.currentChannelId) {
|
||||
PushNotifications.clearChannelNotifications(this.props.currentChannelId);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import {
|
|||
import Icon from 'react-native-vector-icons/Ionicons';
|
||||
|
||||
import Badge from 'app/components/badge';
|
||||
import PushNotifications from 'app/push_notifications';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
|
@ -61,10 +60,6 @@ class ChannelDrawerButton extends PureComponent {
|
|||
EventEmitter.on('drawer_opacity', this.setOpacity);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
PushNotifications.setApplicationIconBadgeNumber(this.props.mentionCount);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
EventEmitter.off('drawer_opacity', this.setOpacity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ NSString* const NotificationClearAction = @"clear";
|
|||
[self cleanNotificationsFromChannel:channelId andUpdateBadge:NO];
|
||||
} else if (state == UIApplicationStateInactive) {
|
||||
// When the notification is opened
|
||||
[self cleanNotificationsFromChannel:channelId andUpdateBadge:YES];
|
||||
[self cleanNotificationsFromChannel:channelId andUpdateBadge:NO];
|
||||
}
|
||||
|
||||
[RNNotifications didReceiveRemoteNotification:userInfo];
|
||||
|
|
|
|||
Loading…
Reference in a new issue