customerio / customerio-expo-plugin

MIT License
11 stars 9 forks source link

Expo Notifications.addNotificationResponseReceivedListener not working on iOS #126

Closed Kerumen closed 9 months ago

Kerumen commented 9 months ago

On the latest version (v1.0.0-beta.14), I want to react to notifications tapped in my app. I used to call addNotificationResponseReceivedListener from Expo to receive the notification when a user tap on it. It was working before on iOS thanks to the configuration option handleNotificationClick: false in 1.0.0-beta.13. But on the latest version, this config option doesn't exist anymore and I don't receive the notification in my code.

It's still working fine on Android. How can I react to notifications click on iOS with the latest version?

levibostian commented 9 months ago

Thanks for asking about this. Indeed, handleNotificationClick config option has been deprecated in v1.0.0-beta.14. This deprecation was made because of a new feature in the latest native iOS SDK that handles notification clicks, without interfering with other SDKs such as expo-notifications.

Because of this new iOS feature, our goal is that you no longer need to use handleNotificationClick: false in your app. Our goal is that you can install the Customer.io SDK as well as another SDK such as expo-notifications and the 2 SDKs can both handle when a push is clicked. I understand that you're having issues with this currently and I'll try to help with that.

From our testing with v1.0.0-beta.14 and expo-notifications, we have been able to receive callbacks from the addNotificationResponseReceivedListener function when a notification (not sent from Customer.io) is clicked.

In order to quickly help you with this scenario, I suggest you send our team some files that demonstrates your app's environment to see if we can reproduce the issue.

Send an email to win@customer.io referencing this GitHub issue as well as these files:

Note: While we help you get your callbacks working, I want to note that handleNotificationClick has been deprecated, there is a config option autoTrackPushEvents: false that can be used instead. Feel free to try this config option as a workaround to get your app working as it was in v1.0.0-beta.13.

Hope you have a great day! Thanks again for asking this question.

Kerumen commented 9 months ago

From our testing with v1.0.0-beta.14 and expo-notifications, we have been able to receive callbacks from the addNotificationResponseReceivedListener function when a notification (not sent from Customer.io) is clicked.

Sorry if I was not clear enough but I want to receive the callback even for Customer.io notifications. It's not possible anymore?

levibostian commented 9 months ago

I want to receive the callback even for Customer.io notifications

Thanks for clarifying this. Handling clicks on Customer.io push notifications is a little different. For handling clicks not sent from Customer.io, expo-notifications callback functions is a good approach.

As for handling a Customer.io push...

If you are looking for a similar experience to expo-notifications of having a callback function (such as addNotificationResponseReceivedListener) be called when a Customer.io push notification is clicked, unfortunately, this is a feature that has not been implemented yet. We have an internal ticket tracking this feature and I will add a +1 based on this conversation.

Until this feature is released, I suggest using deep links in your app to get notified when a Customer.io push is clicked on.

If you add a deep link URL in the rich push editor of Customer.io: CleanShot 2024-02-15 at 10 33 49@2x

the Customer.io SDK will open that deep link URL when a push is clicked. This will call a callback function in your app that you can then use to handle that push notification being clicked on.

I understand that this option may require more setup for you within your app by enabling deep links. The improvements made in 1.0.0-beta.14 are designed to reduce the amount of work developers previously needed to do to handle a Customer.io push notification. Especially in regards to reporting push opened metrics. By having the Customer.io SDK completely take care of handling a push sent from Customer.io, we hope that this will make your experience with Customer.io more reliable. Thanks for sharing this great feedback so we can continue making the SDK setup even easier for you in the future.

Kerumen commented 9 months ago

Thanks for the detailed explanations! We are currently switching from expo-notifications to Customer.io SDK for push notifications and sometimes we send external links in deep links that we want to open in the internal web browser of our app. I will switch the implementation to a deep link in a screen of our app and handle the external link in that screen (opening the internal web browser). It should work! But ideally if the SDK could expose a callback function to listen to the notifications received, that would be great.

levibostian commented 9 months ago

That plan sounds like it should work. Reach out to us if you encounter issues.

Agreed, exposing a callback function would be a great addition. I added a +1 to the internal feature request. I am not able to provide any dates to expect a feature like this unfortunately. I am glad to see that you have a solution for the time being.

jetaix commented 3 months ago

Hi @levibostian any update on the priority of this? We have some use cases where the callback could be helpful for our business? (track, display specific UI after tapped, ...).