Verified Commit 29e61dc6 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Properly handle iOS notifications permission denial

parent b1fcc71c
......@@ -7,10 +7,22 @@ import * as pushNotificationsActions from '../actions/pushNotifications';
const register = function* register() {
const token = yield select(tokenSelector);
if (token === undefined) {
// There is no token, thus do nothing
return;
}
let pushToken;
if (Platform.OS === 'ios') {
yield call(FCM.requestPermissions);
pushToken = yield call(FCM.getFCMToken);
try {
// this throws an error when the permissions are denied
yield call(FCM.requestPermissions);
pushToken = yield call(FCM.getFCMToken);
} catch (err) {
// return and do nothing since we have no token
return;
}
} else {
pushToken = yield call(FCM.getFCMToken);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment