小编Sha*_*que的帖子

iOS 中的 React Native OneSign 后台通知问题

我按照本指南在我的反应本机应用程序中设置 OneSignal 后台通知:https ://documentation.onesignal.com/docs/rn-android-native-module-setup-for-notification-service-extension#ios-notification-服务扩展模块

当我通过 Xcode 将应用程序直接安装到我的设备时,后台通知按预期工作。但是当我存档构建并从 TestFlight 安装它时,后台通知不起作用。除非emitNotificationEvent我添加的事件没有被触发,即使收到了推送通知。

当我在 Xcode 中跟踪存档构建的问题(使用设备控制台)时,_instance注意到NotificationExtensionModule.m. 有人遇到过类似的问题或知道可能是什么原因吗?

笔记

  • Xcode 版本:13.4
  • 在两种情况下接收推送通知(来自试飞或直接安装)
  • 要将新版本放入 TestFlight,用于增加具有相同版本号的内部版本号。
  • 尝试清理构建文件夹,重新安装 Pod,仍然没有任何效果

添加代码片段以进一步了解我的问题:

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

5
推荐指数
1
解决办法
791
查看次数