Clear iOS notification on resume/open (#520)
This commit is contained in:
parent
ba9cc637d3
commit
afb2e6fd92
|
@ -31,12 +31,13 @@ const onNotification = (notification) => {
|
|||
}
|
||||
};
|
||||
|
||||
const getDeviceToken = () => PushNotification.getDeviceToken();
|
||||
const setBadgeCount = count => PushNotification.setBadgeCount(count);
|
||||
const initializePushNotifications = () => {
|
||||
PushNotification.configure({
|
||||
onNotification
|
||||
});
|
||||
setBadgeCount();
|
||||
};
|
||||
|
||||
const getDeviceToken = () => PushNotification.getDeviceToken();
|
||||
|
||||
export { initializePushNotifications, getDeviceToken };
|
||||
export { initializePushNotifications, getDeviceToken, setBadgeCount };
|
||||
|
|
|
@ -19,6 +19,8 @@ class PushNotification {
|
|||
return this.deviceToken;
|
||||
}
|
||||
|
||||
setBadgeCount = () => {}
|
||||
|
||||
configure(params) {
|
||||
this.onRegister = params.onRegister;
|
||||
this.onNotification = params.onNotification;
|
||||
|
|
|
@ -21,6 +21,10 @@ class PushNotification {
|
|||
return this.deviceToken;
|
||||
}
|
||||
|
||||
setBadgeCount = (count = 0) => {
|
||||
NotificationsIOS.setBadgesCount(count);
|
||||
}
|
||||
|
||||
configure(params) {
|
||||
this.onRegister = params.onRegister;
|
||||
this.onNotification = params.onNotification;
|
||||
|
|
|
@ -3,6 +3,7 @@ import { FOREGROUND, BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-ap
|
|||
|
||||
import RocketChat from '../lib/rocketchat';
|
||||
import log from '../utils/log';
|
||||
import { setBadgeCount } from '../push';
|
||||
|
||||
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
||||
const appRoot = yield select(state => state.app.root);
|
||||
|
@ -14,6 +15,7 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
setBadgeCount();
|
||||
return yield RocketChat.setUserPresenceOnline();
|
||||
} catch (e) {
|
||||
log('appHasComeBackToForeground', e);
|
||||
|
|
Loading…
Reference in New Issue