I’m trying to send interactive push notifications (notifications with buttons). I can send normal remote and local push notifications fine, however I cannot send remote interactive push notifications only local ones.
As per this section in the docs, I create a category:
Notifications.createCategoryAsync('daily_question', [
{
actionId: 'yes',
buttonTitle: 'Yes',
},
{
actionId: 'no',
buttonTitle: 'No',
},
]);
And on the backend I add the _category
key to the message object as per this section in the docs.
For the _category
key in the message object I’ve tried both daily_question
and @username/appName:daily_question
for the values, but neither add the interactive buttons.
So far, as a work around, I have two notifications show, one remote and one local (with the interactive buttons in the notification card) but this doesn’t seem like a good solution as I really only want to send one notification to the user. My solution for this is as follows:
let notificationReceived = false;
Notifications.addListener(() => {
if (notificationReceived) {
return;
}
notificationReceived = true;
Notifications.presentLocalNotificationAsync({
title: '...',
body: '...',
categoryId: 'daily_question',
});
});
Is there a way to send a message, to the app, from the server, in a background process (without showing a notification) and then let the app handle showing a local notification with interactive buttons?