@haydncomley wrote:
At the moment I am using Firebase and Capacitor APIs for Push and Local Notifications.
After reading into the subject of notifications and the differences between Data & Display notifications I am at a roadblock.What I would like to achieve is to send a data notification from a Cloud Function on Firebase that is then presented to the user when the app is in the background (dead or inactive), a key feature being that a user can reply inline with this notification - like you can do on any chat application.
I can partially achieve this by sending data notifications, listening for them with with Push Notification API
PushNotifications.addListener('pushNotificationReceived' => (notification: PushNotification) => {})
And then displaying them with the local notification API.
async showNativeNotification(data: any) { if ((await App.getState()).isActive) { console.log('Application Open - Notification Suppressed', data); return; } let notifTitle = 'Knapsack'; const prefColour = await this.prefService.getPreferences(); if (data.location) { notifTitle = `${data.location.topic.name} - ${data.location.workspace.name}`; } LocalNotifications.schedule({ notifications: [{ id: 1, title: notifTitle, body: `${data.sender ? `${data.sender.name}: ` : ''}${data.message.snippet}`, attachments: null, iconColor: prefColour.userPrefs.theme ? UtilityHelper.themePropToHex(prefColour.userPrefs.theme.properties.primary) : '#f74258', actionTypeId: 'chat_message', extra: data }], }); }
Actions Being Registered Earlier in the App:
LocalNotifications.registerActionTypes({ types: [ { id: 'chat_message', actions: [ { id: 'mute', title: 'Mute', destructive: true, foreground: true }, { id: 'reply', title: 'Reply', input: true, destructive: true, foreground: false, inputPlaceholder: 'Ab', inputButtonTitle: 'Send' } ] } ] });
This produces the exact thing I would like when the app is in the background somewhere.
However the issue is as it’s a data notification this function never fires when the app is completely killed.If i send a display notification however then this comes through fine when the app is inactive & when the app has been killed, however to my knowledge there is no way of allowing input onto these, and registering events. Am I missing something or is this purley something that doesn’t exist at the moment?
I can make to with the boring un-interactive notifications but would love more flexibility. Any information or help on this topic would be much appreciated.
Posts: 1
Participants: 1