invertase / notifee

⚛️ A feature rich notifications library for React Native.
https://notifee.app
Apache License 2.0
1.75k stars 201 forks source link

[iOS] Foreground APNS notification not triggering listener / not handled #1041

Open ceebows opened 1 month ago

ceebows commented 1 month ago

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();
        };
    }, []);
douglasscriptore commented 1 month ago

+1

yannickpschroeder commented 3 weeks ago

+1

Flotemer commented 14 hours ago

+1