interactive notifications

  1. SDK Version:44
  2. Platforms(Android/iOS):
  3. Package: expo-notifications

Hello, I’m trying to set up interactive notifications based on the documentation . I’ve created the category using the setNotificationCategoryAsync() and provided all necessary fields. However when I receive the notification the actions defined in for that category are not applied at all.

is there any working example for this , so far anything related to this topic is outdated .

thank you

If you have some sample code, someone here may be able to suggest something. One thing that’s really important is to make sure that identifier/ categoryIdentifier match up between the category and the notification (see here).

Hello Keith,

thank you so much for taking the time to provide an answer , unfortunately the code is a production code therefor I will not be able to share it here . However I did follow the documentation you referred to as I mentioned in my first post. I’ve noticed one thing though. my identifier has “@” and “/” in it could that be an issue ?

I’m not aware of any restrictions on what characters can be in this identifier

my indentifier looks like this @xxx/xxx and and I set the categories by doing the following based on the documentation Notifications.setNotificationCategoryAsync(@xxx/xxx, [ { identifier: "identifier1", buttonTitle: "title1, }, { identifier: "identifier2", buttonTitle: "title2, }, { identifier: "identifier3", buttonTitle: "title3, }, ]);

when I console log the categories using Notifications.getNotificationCategoriesAsync().then((c) => console.log("CATEGORY", c) );
identifer looks like identifier:@xxxxxx notice the slash(“/”) is removed.

also the documentation says : Don’t use the characters : or - in your category identifier. If you do, categories might not work as expected.. this seems to suggest that categoryIdentifier can be anything. but your answer suggests that it has to match the experienceId which we have no control over . This is very confusing :sweat_smile: :smiling_face_with_tear:

is there any working implementation of this? all examples of this functionality are outdated and the docs don’t cover much

I don’t think the categoryIdentifier should match the experienceId - if that was the case, you could only have one category per app.

I got it to work like this:

Notifications.setNotificationCategoryAsync('actionNotification1', [
    {
      identifier: 'action1',
      buttonTitle: 'Action 1',
    },
    {
      identifier: 'action2',
      buttonTitle: 'Action 2',
    }
  ])

Once I did that, this cURL caused the actions to show up in my notification:

curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
  "to": "ExponentPushToken[XXXXXX]",
  "title":"hello",
  "body": "world",
  "categoryId": "actionNotification1"
}'

Hello again Keith,

thanks so much for your help . the categoryId was the missing piece as it’s not mentioned anywhere in the docs . some say it’s _category which is what I was using . This should be documented .

thank you so much

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.