daz*_*mic 5 ios react-native detox
我正在 Detox 上编写 e2e 测试,以测试 React Native 中的 Firebase 应用程序。看起来对firebase.auth().signInWithPhoneNumber(number)调度的调用会调度调度队列上的某些项目,但这些项目似乎从未出列,因此测试无法继续。我的预感是登录调用发出的网络请求永远无法解析。\n以下是日志:
detox[41991] INFO: [APP_STATUS] The app is busy with the following tasks:\n\xe2\x80\xa2 There are 2 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".\n\xe2\x80\xa2 Run loop "Main Run Loop" is awake.\nRun Code Online (Sandbox Code Playgroud)\n我已阅读此故障排除指南,看起来该操作是在主线程(本机)上进行的,并且问题是等待太多的问题。
\n有没有办法检查调度队列上的项目以进一步了解它们是什么?我尝试运行/usr/bin/xcrun simctl spawn <device> log stream --level debug --style compact --predicate \'process == "myapp"\'但我不明白输出。如果有用的话我可以上传日志。
我希望我可以发布一些某种类型的日志,有人可以帮助我找到调度队列中的项目的原因或为我指出正确的方向。\n我没有本机开发经验,因此设备系统日志和Objective C/Swift 代码对我来说毫无意义。\n谢谢
\n19.4.20.67.4v12.22.6iPhone 11 SimulatoriOSjest-circus回答这个问题:不,没有简单的方法来检查调度队列。您必须仔细检查应用程序的内部结构,添加日志记录并注释掉代码部分,直到找出导致问题的原因。
编辑:截至 2022 年 8 月 7 日,更新您的 @react-native-firebase/* 软件包 >=v15.3.0 应该可以解决该问题。
关于您的具体同步问题...
@react-native-firebase/messaging此问题是由 [!]实现中的错误引起的application: didReceiveRemoteNotification: fetchCompletionHandler:。
他们的实现陷入了一场竞争,FIRAuth/didReceiveRemoteNotification如果 FIRAuth 的函数首先运行,则会导致react-native-firebase/messaging 不回调完成处理程序。
PR正在进行中,以便在上游修复此问题,但与此同时,如果您已设置patch-package ,则可以使用以下补丁:
diff --git a/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m b/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
index ec26b70..743fe41 100644
--- a/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
+++ b/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
@@ -123,6 +123,18 @@ - (void)application:(UIApplication *)application
completionHandler(UIBackgroundFetchResultNoData);
return;
}
+
+ // If the notification is a probe notification, always call the completion
+ // handler with UIBackgroundFetchResultNoData.
+ //
+ // This fixes a race condition between `FIRAuth/didReceiveRemoteNotification` and this
+ // module causing detox to hang when `FIRAuth/didReceiveRemoteNotification` is called first.
+ // see /sf/ask/5043146531/
+ NSDictionary *data = userInfo[@"com.google.firebase.auth"];
+ if (data && data[@"warning"]) {
+ completionHandler(UIBackgroundFetchResultNoData);
+ return;
+ }
#endif
[[NSNotificationCenter defaultCenter]
Run Code Online (Sandbox Code Playgroud)
[!]在@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
| 归档时间: |
|
| 查看次数: |
2288 次 |
| 最近记录: |