wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

Background notifications with mutable-content flag (iOS) #848

Closed artdevgame closed 2 years ago

artdevgame commented 2 years ago

Hello 👋🏻

I'm using this plugin to consume push notifications dispatched by the Twilio Conversation API.

I have wired up my AppDelegate as instructed and it includes the implementation of the didReceiveRemoteNotification method, however, it never seems to get triggered (I added a NSLog to try and debug and no output occurred)

This is an example payload that Twilio is sending (I have no control over the actual structure):

{
    aps =     {
        alert =         {
            body = "[{\"type\":\"paragraph\",\"children\":[{\"text\":\"yo\"}]}]";
        };
        "mutable-content" = 1;
    };
    author = "045ce068822a13168def8943fce894b38e4e1968";
    "conversation_sid" = CHc7ab9d45c3774796940931887f4c0226;
    "conversation_title" = "Test convo";
    "message_index" = 40;
    "message_sid" = IM04c2c8eae6824a29a6dead82eb64427b;
    "twi_message_id" = RUdd90d3549e57dcdabb0484a7564f70c0;
    "twi_message_type" = "twilio.conversations.new_message";
}

I've been able to intercept the push with a 'notification service extension' but ideally I'd like to hook into the registerNotificationReceivedBackground function in JS, which isn't executed at the moment.

Should the Twilio payload in its current form cause didReceiveBackgroundNotification to execute or not? If not, is there something I can do inside the service extension to make it execute?

artdevgame commented 2 years ago

@DanielEliraz Sorry to ping you directly on this one, but you seem to be the only active contributor and I'm looking for an answer on the above, even if it's to say 'that won't work' kind of thing. Do you happen to know the answer?

DanielEliraz commented 2 years ago

No problem @artdevgame. Can you make Twilio send it without the alert entry in the aps object. This is what Apple demands

DanielEliraz commented 2 years ago

I'll add it to the documentation since many devs (including me 😄 ) missed that

artdevgame commented 2 years ago

No problem @artdevgame. Can you make Twilio send it without the alert entry in the aps object. This is what Apple demands

No, unfortunately. I have no control over that payload at all 😢 , though I'll forward that link on to their tech support and see what they say. Thanks.