()
| 512 | } |
| 513 | |
| 514 | async ensureAndroidPushNotifsEnabled() { |
| 515 | const permissionPromisesResult = await Promise.all([ |
| 516 | CommAndroidNotifications.hasPermission(), |
| 517 | CommAndroidNotifications.canRequestNotificationsPermissionFromUser(), |
| 518 | ]); |
| 519 | |
| 520 | let [hasPermission] = permissionPromisesResult; |
| 521 | const [, canRequestPermission] = permissionPromisesResult; |
| 522 | |
| 523 | if (!hasPermission && canRequestPermission) { |
| 524 | const permissionResponse = await (async () => { |
| 525 | // We issue a call to sleep to match iOS behavior where prompt |
| 526 | // doesn't appear immediately but after logged-out modal disappears |
| 527 | await sleep(10); |
| 528 | return await this.requestAndroidNotificationsPermission(); |
| 529 | })(); |
| 530 | hasPermission = permissionResponse; |
| 531 | } |
| 532 | |
| 533 | if (!hasPermission) { |
| 534 | this.failedToRegisterPushPermissionsAndroid(!canRequestPermission); |
| 535 | return; |
| 536 | } |
| 537 | |
| 538 | try { |
| 539 | const fcmToken = await CommAndroidNotifications.getToken(); |
| 540 | await this.handleAndroidDeviceToken(fcmToken); |
| 541 | } catch (e) { |
| 542 | this.failedToRegisterPushPermissionsAndroid(!canRequestPermission); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | requestAndroidNotificationsPermission = (): Promise<boolean> => { |
| 547 | if (!this.androidNotificationsPermissionPromise) { |
no test coverage detected