forked from Blendman974/faceclaw
Notification listener rebinding
This commit is contained in:
1 parent
75e0b15d62
commit
bf2addd287
6 files changed
+296
-68
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { isNotificationListenerEnabled, requestNotificationListenerAccess } from "../../native/notification-access";
|
||||
import { notificationListenerState, requestNotificationListenerAccess } from "../../native/notification-access";
|
||||
import { type AppDefinition } from "../app-definition";
|
||||
import { createNotificationsAppWindow, NOTIFICATIONS_SURFACE_ID, NOTIFICATIONS_WINDOW_ID } from "./notifications-app";
|
||||
|
||||
@@ -7,10 +7,11 @@ const notificationsApp: AppDefinition = {
|
||||
title: "Notifications",
|
||||
icon: "bell",
|
||||
launch: (ctx) => {
|
||||
// Without notification-listener access the tray reads as empty; prompt
|
||||
// the user on the phone so the on-glasses "grant permission" message is
|
||||
// actionable. The app still opens to show that message.
|
||||
if (!isNotificationListenerEnabled()) {
|
||||
// Without notification-listener access (or with a listener Android won't
|
||||
// rebind) the tray reads as empty; open the access screen on the phone so
|
||||
// the on-glasses message is actionable. The app still opens to show it.
|
||||
const listenerState = notificationListenerState();
|
||||
if (listenerState === "no-access" || listenerState === "stuck") {
|
||||
requestNotificationListenerAccess();
|
||||
}
|
||||
return ctx.launchInProcessApp(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow);
|
||||
|
||||
Reference in new issue
Block a user