forked from Ivasoft/mattermost-mobile
Request permissions for Android push notifications and refactor code to use network client (#7059)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user