expo-server-sdk-python icon indicating copy to clipboard operation
expo-server-sdk-python copied to clipboard

Add support for ios background events

Open howieweiner opened this issue 2 years ago • 1 comments

According to the expo.dev docs, in order to handle notifications in the background on iOS, it is necessary to send the following addtional data in the payload:

"content-available": 1

I am currently achieving this by extending the PushMessage class as described in the code:

class ExpoPushMessage(PushMessage):
    def get_payload(self):
        """
        Override the get_payload method to add the content-available flag
        :return:
        """
        payload = super().get_payload()
        payload["content-available"] = 1
        return payload

I imagine that many expo-notification users would like to process background events, so the addition of another attribute would be beneficial.

howieweiner avatar Mar 01 '23 12:03 howieweiner

+1

Also.. for me, instead of content-available, I needed to use _contentAvailable.

payload["_contentAvailable"] = True

kevin-wcs avatar Feb 26 '25 16:02 kevin-wcs