Page MenuHomePhabricator

Implement native method to check for notifications permissions and use it in JavaScript
ClosedPublic

Authored by marcin on Jan 25 2023, 1:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 1:51 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:58 AM
Unknown Object (File)
Apr 17 2024, 4:52 AM
Subscribers

Details

Summary

This differential implements native method to check for notifications permissions and uses it in JavaScript. Relevant types are updated as well.

Test Plan

Build the app and open it. Open settings and revoke comm notifications permissions. Go back to app and ensure that "Failed to register push notifs" message is displayed and no notifications
are delivered. Close the app. Go back to settings, bring notifications permissions back. Open the app, ensure that previous message is not displayed and notifications are succesfully delivered.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Jan 25 2023, 1:18 AM
Harbormaster failed remote builds in B15619: Diff 21293!
tomek added inline comments.
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
99 ↗(On Diff #21295)

A Boolean has three values: Boolean.FALSE, Boolean.TRUE, null. What happens when we call promise.resolve(null)? Is it transformed to js boolean as false? If that's not the case, we can convert Boolean to boolean on java side using Boolean.TRUE.equals(...).

This revision is now accepted and ready to land.Jan 26 2023, 3:06 AM
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
99 ↗(On Diff #21295)

According to docs of this method: https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#areNotificationsEnabled() it returns primitive type boolean. Assigning it to class type Boolean works but it is my silly mistake to do it this way. I will change type to boolean here.