don't display notification in ios device when use react-native-fcm

275 Views Asked by At

i'm using from react-native-fcm for recieve pushNotification and do all config in this document(https://github.com/evollu/react-native-fcm) in ios device only recieve notification and call notificationListener that checked by console.log but dont display notification message and alert even test FCM.presentLocalNotification for show local notification still dont show notification

    async componentDidMount() {
        if (Platform.OS === 'ios') {
            try {
                const result = await FCM.requestPermissions({ badge: false, sound: true, alert: true });
            } catch (e) {
                console.error(e);
            }

            FCM.getFCMToken().then(token => {
                if (token !== undefined) {
                    // this.props.onChangeToken(token);
                } else {
                    console.log('TOKEN (getFCMToken)', 'null');
                }
            });

            // FCM.getAPNSToken().then(token => {
            //     this.props.onAPNToken(token);
            // });

            FCM.getInitialNotification().then(notif => {
                console.log('INITIAL NOTIFICATION', notif);
            });

            this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {

                console.log("  >> notificationListener: ", notif)

                if (notif.local_notification) return;
                FCM.presentLocalNotification({
                    body: 'tdtydt',
                    priority: "high",
                    title: 'notif.fcm.title',
                    sound: "default",
                    show_in_foreground: true,
                    local_notification: true,
                   icon: "ic_launcher",
                    status: "400"
                });

            });
            this.refreshTokenListener = FCM.on(FCMEvent.RefreshToken, token => {
                console.log('TOKEN (refreshUnsubscribe)', token);
                this.props.onChangeToken(token);
            });

            FCM.enableDirectChannel();
            this.channelConnectionListener = FCM.on(FCMEvent.DirectChannelConnectionChanged, (data) => {
                console.log(`direct channel connected${data}`);
            });
            setTimeout(() => {
                FCM.isDirectChannelEstablished().then(d => console.log('isDirectChannelEstablished', d));
            }, 500);
}
0

There are 0 best solutions below