Fixed crash on emulator

This commit is contained in:
keplyx 2020-03-12 18:13:25 +01:00
parent 4c6905a5d5
commit 72693d14f2

View file

@ -94,10 +94,14 @@ export default class NotificationsManager {
static async initExpoToken() {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
if (token === '') {
await NotificationsManager.askPermissions();
let expoToken = await Notifications.getExpoPushTokenAsync();
// Save token for instant use later on
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
try {
await NotificationsManager.askPermissions();
let expoToken = await Notifications.getExpoPushTokenAsync();
// Save token for instant use later on
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
} catch(e) {
console.log(e);
}
}
}