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 = () => {
|
const initializePushNotifications = () => {
|
||||||
PushNotification.configure({
|
PushNotification.configure({
|
||||||
onNotification
|
onNotification
|
||||||
});
|
});
|
||||||
|
setBadgeCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDeviceToken = () => PushNotification.getDeviceToken();
|
export { initializePushNotifications, getDeviceToken, setBadgeCount };
|
||||||
|
|
||||||
export { initializePushNotifications, getDeviceToken };
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ class PushNotification {
|
||||||
return this.deviceToken;
|
return this.deviceToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBadgeCount = () => {}
|
||||||
|
|
||||||
configure(params) {
|
configure(params) {
|
||||||
this.onRegister = params.onRegister;
|
this.onRegister = params.onRegister;
|
||||||
this.onNotification = params.onNotification;
|
this.onNotification = params.onNotification;
|
||||||
|
|
|
@ -21,6 +21,10 @@ class PushNotification {
|
||||||
return this.deviceToken;
|
return this.deviceToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBadgeCount = (count = 0) => {
|
||||||
|
NotificationsIOS.setBadgesCount(count);
|
||||||
|
}
|
||||||
|
|
||||||
configure(params) {
|
configure(params) {
|
||||||
this.onRegister = params.onRegister;
|
this.onRegister = params.onRegister;
|
||||||
this.onNotification = params.onNotification;
|
this.onNotification = params.onNotification;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { FOREGROUND, BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-ap
|
||||||
|
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import log from '../utils/log';
|
import log from '../utils/log';
|
||||||
|
import { setBadgeCount } from '../push';
|
||||||
|
|
||||||
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
||||||
const appRoot = yield select(state => state.app.root);
|
const appRoot = yield select(state => state.app.root);
|
||||||
|
@ -14,6 +15,7 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
setBadgeCount();
|
||||||
return yield RocketChat.setUserPresenceOnline();
|
return yield RocketChat.setUserPresenceOnline();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('appHasComeBackToForeground', e);
|
log('appHasComeBackToForeground', e);
|
||||||
|
|
Loading…
Reference in New Issue