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() { static async initExpoToken() {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current; let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
if (token === '') { if (token === '') {
await NotificationsManager.askPermissions(); try {
let expoToken = await Notifications.getExpoPushTokenAsync(); await NotificationsManager.askPermissions();
// Save token for instant use later on let expoToken = await Notifications.getExpoPushTokenAsync();
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken); // Save token for instant use later on
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
} catch(e) {
console.log(e);
}
} }
} }