Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): handle response events for remote notifications [next] #236

Merged
merged 3 commits into from
Sep 26, 2022

Conversation

helenaford
Copy link
Member

@helenaford helenaford commented Nov 17, 2021

@next release 5.0.0-0
So far includes the following events for remote notifications:

  • PRESSED
  • ACTION_PRESSED
  • DISMISSED

Release Notes:

  • [BREAKING] On iOS, onNotificationOpenedApp and getInitialNotification from RNFB Messaging will no longer trigger as notifee will handle the event.
  • [feat] Can support quick actions from remote notifications without need of a NSE

@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #236 (92f168b) into main (892cab9) will not change coverage.
The diff coverage is n/a.

❗ Current head 92f168b differs from pull request most recent head 36acf66. Consider uploading reports for the commit 36acf66 to get more accurate results

@@           Coverage Diff           @@
##             main     #236   +/-   ##
=======================================
  Coverage   77.33%   77.33%           
=======================================
  Files          32       32           
  Lines        1658     1658           
  Branches      533      553   +20     
=======================================
  Hits         1282     1282           
+ Misses        375      328   -47     
- Partials        1       48   +47     

@helenaford helenaford changed the title feat(ios): handle response events for remote notifications (#228) feat(ios): handle response events for remote notifications [ALPHA] Nov 17, 2021
@helenaford helenaford changed the title feat(ios): handle response events for remote notifications [ALPHA] feat(ios): handle response events for remote notifications [alpha] Nov 17, 2021
@helenaford helenaford changed the title feat(ios): handle response events for remote notifications [alpha] feat(ios): handle response events for remote notifications [next] Nov 18, 2021
@zenshayan
Copy link

Hi, iOS quick actions from remote notifications without need of a NSE works perfectly well. However, foreground notifications on iOS no longer work

@johnf
Copy link

johnf commented May 5, 2022

@helenaford is this PR still relevant?

I'm trying to get PRESS events from remote notifications on iOS. Is this PR something to try or is it because I fon't have an NSE?

@helenaford helenaford force-pushed the helenaford/feat-apns-support branch from 8ffedb2 to edff37f Compare June 1, 2022 22:48
@helenaford
Copy link
Member Author

@johnf Yes, it is.

I've updated this branch with the latest changes and have published it as a @next release (v6.0.0-0).

@finalight
Copy link

finalight commented Jun 7, 2022

when can we have this feature?

because on iOS, we can't receive click event, unless there's other ways for now?

@johnf
Copy link

johnf commented Jul 5, 2022

@helenaford I can confirm that I've tested this and it works as expected.
Rolling It out to production a bit later this week for broader testing

@frozencap
Copy link

This PR is amazing, along with #229 looks like there's a whole bunch of Notifee caveats for iOS being deprecated 🎉
Awesome stuff guys and gals, thanks for the ongoing development, this is the real deal
patiently waits for the drop

@helenaford helenaford merged commit 3d7a8ce into main Sep 26, 2022
@helenaford helenaford deleted the helenaford/feat-apns-support branch September 26, 2022 01:08
@MEsteves22
Copy link

MEsteves22 commented Oct 28, 2022

Hello,

First, I would like to thank you for your work and this amazing library!

I've upgraded Notifee to version 7.0.4, and I'm having some trouble understanding how I'm able to get which notification has caused my application to open when it was quit/closed. Previously, I was using onNotificationOpenedApp and getInitialNotification from RNFB to execute some code after the app opens when the user clicks on a notification. However, these events no longer work on iOS as mentioned in the release notes.

I've followed this tutorial (https://notifee.app/react-native/docs/ios/remote-notification-support), set up NSE (which I was already using to attach an image) and I'm receiving my notifications. However, when I click on a notification when the app is quit, the onForegroundEvent from Notifee is never called. It's only called when the app is in the foreground or background. The getInitialNotification event from Notifee is called but the documentation is saying that "getInitialNotification is deprecated on iOS in favour of the PRESS event received by the onForegroundEvent event handler".

I don't know if I'm misunderstanding the documentation or if I'm missing something.

Thank you!

@billnbell
Copy link

It says you don't need NSE... This allows quick actions from remote notifications to be supported without the need of a NSE... But we need more documentation

@venux92
Copy link

venux92 commented Nov 19, 2022

@MEsteves22

This is my actual setup on 7.1.0

notifee.onForegroundEvent(async ({ type, detail }) => {
    switch (type) {
        case EventType.PRESS:
           await this.handleNotification(detail)
           break
        case EventType.ACTION_PRESS:
           await this.handleAction(detail)
           break
}})

And it works fine for me on iOS, I just switched from 5.5.0 to 7.1.0 but I was already using it that way with 5.5.0

I still use a NSE as well for my notification image

Hopefully this helps you

@MEsteves22
Copy link

@venux92 Thank you for your help 🙏

// we only care about notifications created through notifee
// handle notification outside of notifee
if (notifeeNotification == nil) {
notifeeNotification = [NotifeeCoreUtil parseUNNotificationRequest:response.notification.request];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI it looks like there is a conflict with the Braze SDK with this line
To reproduce : install notifee and braze. Open your app, send a Braze test IAM campaign, click on the notification to show the IAM. No IAM is shown.
And possibly conflicts with other SDKs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround is patching parseUNNotificationRequest with

+  if (userInfo != nil && userInfo[keyToExclude] != nil) {
+      return nil;
+  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no! Looks like an easy enough local patch-package fix for you (I'd bet $1 you already have that running ;-) ) but a PR here is something we could integrate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants