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

[iOS] Foreground APNS notification not triggering listener / not handled #1041 (Duplicate since other closed) #1109

Closed
ceebows opened this issue Sep 28, 2024 · 3 comments

Comments

@ceebows
Copy link

ceebows commented Sep 28, 2024

Reopening issue

Hi,

I am unable to get notifee to work with incoming APNS notification when react native app is in foreground.
None of the event handlers are triggered.
Notifications are received correctly and interaction with them works correctly when app is not in foreground.

Tested on real iOS device. iPhone 14 Pro Max

Versions:
"react-native": "^0.73.7",
"@notifee/react-native": "^7.8.2"
"@react-native-firebase/messaging": "^19.2.2", // i also use FCM

Tested via CURL

curl -v -d '{"aps":{"alert":"Hello from APNS","sound":"default"}}' \
-H "apns-topic: your.bundle.identifier" \
-H "apns-push-type: background" \
-H "authorization: bearer YOUR_JWT_TOKEN" \
--http2 \
https://api.sandbox.push.apple.com/3/device/YOUR_DEVICE_TOKEN

Code handling foreground:

import notifee, { AndroidImportance, EventType } from '@notifee/react-native';
...

useEffect(() => {
        const unsubscribe = notifee.onForegroundEvent(({ type, detail }) => {
            console.log('notifee.onForegroundEvent');
            console.log('type', type);
            console.log('detail', detail);

            switch (type) {
                case EventType.DELIVERED:
                    console.log('User DELIVERED notification', detail.notification);
                    break;
                case EventType.DISMISSED:
                    console.log('User DISMISSED notification', detail.notification);
                    break;
                case EventType.PRESS:
                ...
                break;
                ...
            }
         });

        return () => {
            unsubscribe();
        };
    }, []);
@ceebows
Copy link
Author

ceebows commented Sep 28, 2024

Original Issue #1041

LunatiqueCoder added a commit to LunatiqueCoder/notifee that referenced this issue Oct 8, 2024
LunatiqueCoder added a commit to LunatiqueCoder/notifee that referenced this issue Oct 8, 2024
LunatiqueCoder added a commit to LunatiqueCoder/notifee that referenced this issue Oct 8, 2024
…remote-onForegroundEvent-getInitialNotification' into bug/invertase#1109-invertase#1096-remote-onForegroundEvent-getInitialNotification
LunatiqueCoder added a commit to LunatiqueCoder/notifee that referenced this issue Oct 8, 2024
…Notification - call onForegroundEvent() when app starts from terminated state - same as getInitialNotification()
LunatiqueCoder added a commit to LunatiqueCoder/notifee that referenced this issue Oct 9, 2024
@mikehardy
Copy link
Collaborator

This is not reopening, this is duplicating - I would prefer to maintain a single issue
The original issue has a potential workaround even, closing this and actually reopening that one...

@ceebows
Copy link
Author

ceebows commented Oct 18, 2024

Appreciated. Thank you.

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

No branches or pull requests

2 participants