Skip to content

Feature Recommendation: Callback for raw push object after notification pressed #71

@jehartzog

Description

@jehartzog

We are currently in the process of migrating our react native application to use this lib for all push notifications. We previously used the more general libs react-native-push-notification v4.0.0, @react-native-community/push-notification-ios v1.3.0, and react-native-firebase v5.6.0. We used Iterable to actually send push notifications, but just processed the raw payload ourselves to get the routing & tracking we needed.

So far the integration of this lib has been smooth, but we found one rather custom thing we had set up exposed a gap in the functionality of this (and the underlying iOS/Android) SDK.

Our Current Solution

We previously used the Push Payload field to add our custom JSON which told our app how to handle the push once the user pressed on it.

Example

image

Why This Approach Broke with this SDK

We realized early on that we basically had custom-built a lot of the functionality this SDK provides. We did so a year ago, before this SDK was around. After this lib was released we noticed it would be better to use the OpenURL action, and just insert deep-links that we can use in our app, rather then continuing to use our custom approach.

However we were forced to do so by the fact what we see as two omissions in this SDK:

  1. No callback fires to our app when a user presses on a notification (without using an action to do that)
  2. Since we don't have the above callback, we also can't reliably get a custom payload (`Push Payload) that the user pressed

Here is an example of the kind of callback you'd expect, if you just want to have non-sdk code to have access to the entire push object.

I thought this was an omission in this react-native version, but I dug around the root ios-sdk and saw this wasn't the case. The notification object is processed, tracked, and passed to an action handler, but there's no option to pass the raw object down the client.

Your docs really only mention the ability to read this payload using IterableApi.lastPushPayload in client code to poll for the last payload received, but this leaves out the important cases of if an app is backgrounded/foregrounded when a push is pressed. The client has no way to know a push came through, except perhaps by polling the above to see if there is a change (not an approach we tried or recommend).

Our Workaround

We saw that we could get the 'callback' functionality we desired by using the Open URL action and hooking in there. But it did seem odd to use that there is apparently know way to know if a push is pressed by the user unless it happens to have a openURL or other action attached to it.

Our Recommendation

We were able to quickly work around this, and end up with a cleaner implementation that met our needs. However, I expect most react-native developers will expect an option to hook into the raw push object arrival to enable additional customization/processing if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions