ios - 如何获得最后一次看到的页面分析?
问题描述
我的应用程序的一些用户在完成他们应该做的事情之前意外地退出了应用程序。我怀疑应用程序是否被冻结。如何检查用户最后看到了哪个页面?我想将该数据保存到 Firebase 进行分析。
只是我想知道用户在哪里退出应用程序。
解决方案
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!<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];
}
并建议您可以发送电子邮件告诉开发人员,如果客户允许的话。我认为这个错误信息可以包含崩溃页面的信息,希望这可以帮助你。
推荐阅读
- c# - INotifyPropertyChange 给出窗口激活错误
- php - 检索日期并根据用户时区将其转换为特定时区
- python - Python Unittest:单元测试在引发异常中传递的消息
- flutter - 无法在手机的颤动中获得手机的位置
- amazon-web-services - 跨区域数据库访问如何避免更高的超时
- java - 在 Android 上保存 ArrayList 数据
- powershell - 在 PowerShell 中将 sqlcmd 与 Start-Job 一起使用时出错
- sql - 案例陈述支持
- javascript - 如何检查表单的有效性?
- excel - Excel中预测的嵌套IF问题