我按照本指南在我的反应本机应用程序中设置 OneSignal 后台通知:https ://documentation.onesignal.com/docs/rn-android-native-module-setup-for-notification-service-extension#ios-notification-服务扩展模块
当我通过 Xcode 将应用程序直接安装到我的设备时,后台通知按预期工作。但是当我存档构建并从 TestFlight 安装它时,后台通知不起作用。除非emitNotificationEvent我添加的事件没有被触发,即使收到了推送通知。
当我在 Xcode 中跟踪存档构建的问题(使用设备控制台)时,_instance注意到NotificationExtensionModule.m. 有人遇到过类似的问题或知道可能是什么原因吗?
笔记
添加代码片段以进一步了解我的问题:
AppDelegate.h
#import <Foundation/Foundation.h>
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,RCTBridgeDelegate,UNUserNotificationCenterDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  //access NotificationServiceExtensionModule emitNotificationEvent method
  [NotificationServiceExtensionModule.sharedInstance emitNotificationEvent:userInfo ];
  completionHandler(UIBackgroundFetchResultNoData);
}
Run Code Online (Sandbox Code Playgroud)
通知服务扩展模块.h
#import <foundation/Foundation.h>
// NotificationServiceExtensionModule.h
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
@interface NotificationServiceExtensionModule : …Run Code Online (Sandbox Code Playgroud) ios testflight react-native onesignal react-native-onesignal