我想写一个小样本的科尔多瓦IOS应用程序。我的一个要求是提供一个按钮/链接来允许用户崩溃应用程序。如何崩溃科尔多瓦IOS应用程序
我试图引发异常的CDVUIWebViewNavigationDelegate.m如下,
- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
if([url.path containsString:@"CRASH"])
{
NSLog(@"User crash bookmart with NSException");
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
NSDate *current = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle]; // Set date and time styles
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
NSString *currentTime = [dateFormatter stringFromDate:current];
[userInfo setObject:@"Crash Time" forKey:currentTime];
NSException *ex = [[NSException alloc] initWithName:@"BookmartCrashException" reason:@"User crashed bookmart!" userInfo:userInfo];
[ex raise];
}
...
}
但是,当我尝试,我看到了下面的日志,
2017年9月4日17:09:57.148 HRent [96124:12077045]用户崩溃与NSException的bookmart 2017-09-04 17:09:57.149 HRent [96124:12077045] *** WebKit在> webView中放弃未捕获的异常:decidePolicyForNavigationAction:request:frame:decisionListener:delegate :用户坠毁了bookmart!
的异常已经被舍弃,应用程序还没有崩溃:?(
是否有任何其他的方式崩溃的应用程序肯定还是有一些配置,我可以禁用的WebKit丢弃这样的异常
非常感激你的答案
问候 雷切尔
如果您提供的应用程序崩溃,则您的应用程序将被从App Store拒绝。为什么你需要这样的功能? – the4kman
我不打算把这个样本发布到真正的市场上。这只是我们产品的样品,它将监测混合动力应用。 – rachelnino
如果你想崩溃的应用程序比试试这个..采取一个空的数组并打印它的objectAtIndex任何值。它会崩溃应用 –