Ionic 如何在Testflight上启用Firebase分析调试视图

pbwdgjma  于 2022-12-08  发布在  Ionic
关注(0)|答案(3)|浏览(228)

I am unable to view analytics debug view after I install the app through TestFlight into my test phone.
I have passed in argument -FIRDebugEnabled, and have tried -FIRAnalyticsDebugEnabled but no luck.
-FIRDebugEnabled -FIRAnalyticsDebugEnabled
If I directly installed the app into my test phone through Xcode, the debug view will be available. But if it's installed through TestFlight, the debug view cannot be seen.

sc4hvdpw

sc4hvdpw1#

这可以通过将特殊标志注入Firebase的本地存储器来完成。-FIRDebugEnabled命令行参数正在由以下两者进行检查:FirebaseCoreFirebaseAnalytics框架,前者将标志保存到共享的UserDefaults中,后者使用APMUserDefaults私有类,可以在运行时访问:

if let APMUserDefaults = NSClassFromString("APMUserDefaults") as AnyObject?,
   let userDefaults = APMUserDefaults.perform(#selector(getter: UserDefaults.standard))?.takeUnretainedValue() {
   _ = userDefaults.perform(#selector(NSMutableDictionary.setObject(_:forKey:)),
                            with: true, 
                            with: "/google/measurement/debug_mode")
}
UserDefaults.standard.set(true, forKey: "/google/firebase/debug_mode")
mzillmmw

mzillmmw2#

AppDelegate文件的application:didFinishLaunchingWithOptions:方法的第一行添加以下代码

CommandLine.arguments.append(contentsOf: ["-FIRDebugEnabled", "-FIRAnalyticsDebugEnabled"])
lp0sw83n

lp0sw83n3#

FirebaseApp.configure()之前加入下列程式码:

var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")

然后,转到目标的构建设置,将Release's Optimization level更新为No Optimization [-Onone]
之后,上传到TestFlight。这个方法对我很有效!

相关问题