Request permissions for Android push notifications and refactor code to use network client (#7059)

This commit is contained in:
Elias Nahum
2023-01-31 21:33:35 +02:00
committed by GitHub
parent aa6c1ff058
commit 265b8b2193
10 changed files with 178 additions and 281 deletions

View File

@@ -38,7 +38,7 @@ class PushNotifications {
init(register: boolean) {
if (register) {
Notifications.registerRemoteNotifications();
this.registerIfNeeded();
}
Notifications.events().registerNotificationOpened(this.onNotificationOpened);
@@ -50,11 +50,8 @@ class PushNotifications {
async registerIfNeeded() {
const isRegistered = await Notifications.isRegisteredForRemoteNotifications();
if (!isRegistered) {
if (Platform.OS === 'android') {
Notifications.registerRemoteNotifications();
} else {
await requestNotifications(['alert', 'sound', 'badge']);
}
await requestNotifications(['alert', 'sound', 'badge']);
Notifications.registerRemoteNotifications();
}
}