首页 > 解决方案 > 如何获得最后一次看到的页面分析?

问题描述

我的应用程序的一些用户在完成他们应该做的事情之前意外地退出了应用程序。我怀疑应用程序是否被冻结。如何检查用户最后看到了哪个页面?我想将该数据保存到 Firebase 进行分析。

只是我想知道用户在哪里退出应用程序。

标签: iosfirebase-analytics

解决方案


Apple 提供NSSetUncaughtExceptionHandler来监听应用程序是否崩溃,因此,您可以在应用程序启动时使用此监听器来保存崩溃日志,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
    //get crash report
    [self installUncaughtExceptionHandler]; 
}

实施是:

- (void)installUncaughtExceptionHandler {
   NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
 }
  void UncaughtExceptionHandler(NSException *exception) {
    NSArray *arr = [exception callStackSymbols];
    NSString *reason = [exception reason];
    NSString *name = [exception name];
    NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    NSString *urlStr = [NSString stringWithFormat:@"mailto://developer@googlemail.com?subject=CrashReport&body=YourSuggest!&lt;br><br><br>""errorInfo(%@):<br>%@<br>-----------------------<br>%@<br>---------------------<br>%@",currentVersion,name,reason,[arr componentsJoinedByString:@"<br>"]];
    NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
   [[UIApplication sharedApplication]openURL:url];
 }

并建议您可以发送电子邮件告诉开发人员,如果客户允许的话。我认为这个错误信息可以包含崩溃页面的信息,希望这可以帮助你。


推荐阅读