Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow apps to handle push notification interaction themselves #2587

Open
provokateurin opened this issue Oct 24, 2024 · 1 comment
Open

Allow apps to handle push notification interaction themselves #2587

provokateurin opened this issue Oct 24, 2024 · 1 comment

Comments

@provokateurin
Copy link
Member

provokateurin commented Oct 24, 2024

Currently we just open the corresponding app when the user click on the notification and we simply refresh the notifications bloc when a new one was received, but this is usually not enough:

PushUtils.onPushNotificationReceived = (accountID) async {
final account = _accountsBloc.accountByID(accountID);
if (account == null) {
return;
}
final allAppImplementations = NeonProvider.of<BuiltSet<AppImplementation>>(context);
final app = allAppImplementations.tryFind(notifications.appID) as NotificationsAppInterface?;
if (app == null) {
return;
}
await _accountsBloc.getAppsBlocFor(account).getAppBloc<NotificationsBlocInterface>(app).refresh();
};
PushUtils.onLocalNotificationClicked = (pushNotificationWithAccountID) async {
final account = _accountsBloc.accountByID(pushNotificationWithAccountID.accountID);
if (account == null) {
return;
}
_accountsBloc.setActiveAccount(account);
final allAppImplementations = NeonProvider.of<BuiltSet<AppImplementation>>(context);
final notificationsApp = allAppImplementations.tryFind(notifications.appID) as NotificationsAppInterface?;
if (notificationsApp != null) {
_accountsBloc
.getAppsBlocFor(account)
.getAppBloc<NotificationsBlocInterface>(notificationsApp)
.deleteNotification(pushNotificationWithAccountID.subject.nid!);
}
final app = allAppImplementations.tryFind(pushNotificationWithAccountID.subject.app) ?? notificationsApp;
if (app == null) {
return;
}
await _openAppFromExternal(account, app.id);
};

For example in Talk we actually want to open the room the push notification came from when it is clicked instead of just showing the room list.

The AppImplementation should be able to optionally implement two methods for handling these scenarios manually.

@provokateurin provokateurin changed the title Enable apps to handle push notification interaction themselves Allow apps to handle push notification interaction themselves Oct 24, 2024
@provokateurin provokateurin moved this to Todo in Neon: Talk Oct 30, 2024
@provokateurin
Copy link
Member Author

Also for example clicking on Talk notification is currently "broken" because the IDs don't match and the Notifications App is opened as a fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant