Reactnative IOS pushotification/PushNotificationIOS onNotification 收到通知时不直接调用

Reactnative IOS pushotification/PushNotificationIOS onNotification does not called directly when notification received

我使用了 reactnative PushNotification/PushNotificationIOS 模块,我的问题是当我的设备在前台收到通知时 IOS,函数 onNotification: function(notification) {} 不直接调用是通过点击调用只要 。 我想直接获取通过 pububnub 控制台发送的数据通知 paylaod,无需任何用户交互,此功能在 android 但 ios 并非全部。 控制台没有显示任何可以帮助我解决这个问题的东西,谢谢。

这个函数和导入模块:

import PushNotification from "react-native-push-notification";
import PushNotificationIOS from "@react-native-community/push-notification-ios";

onNotification: function(notification) {
if (Platform.OS=='ios')
{

  console.log('notif',notification)

 
notification.finish(PushNotificationIOS.FetchResult.NoData);

},
 
    onAction: function (notification) {
  
    },
   
    onRegistrationError: function(err) {
  
    },
  permissions: {
      alert: true,
      badge: true,
      sound: true,
    },
   popInitialNotification: true,
    requestPermissions: true,
    senderID: FIREBASE_SENDER_ID,
})
}

这是要发送的对象 pubnub :

{"pn_apns":{
      "aps":{
        "alert": {
            "body": "Course disponible",
            "title": "My course"
        },
        "sound": "beep.wav",
            
"data": { "reference": "ND1004332", "startstation": ""  }
          },


      "pn_push":[
         {
            "push_type":"alert",
            "auth_method":"token",
            "targets":[
               {
                  "environment":"development",
                  "topic":"com.test.fr"
               }
            ],
            "version":"v2"
         }
      ]

}
      
}  
import {Platform} from 'react-native';
import PushNotification from 'react-native-push-notification';
import PushNotificationIOS from "@react-native-community/push-notification-ios"; 
if (Platform.OS === 'ios') {
// Must be outside of any component LifeCycle (such as `componentDidMount`).
PushNotification.configure({
    onNotification: function (notification) {
        console.log("NOTIFICATION:", notification);
        const { foreground, userInteraction, title, message } = notification;
        if (foreground && (title || message) && !userInteraction) PushNotification.localNotification(notification);
        notification.finish(PushNotificationIOS.FetchResult.NoData);
    },

    permissions: {
        // alert: true,
        // badge: true,
        sound: true
      },
});
}