So my app creates user notifications. Sometimes when I tap one of these notification to open the app, it crashes. It happens seemingly randomly and is not easy to reproduce. My app's UNUserNotificationCenterDelegate does something like this (shortened to keep the post concise):
-(void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void(^)(void))completionHandler
{
if (![response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier])
{
//only care about the default action...return out otherwise.
completionHandler();
return;
}
completionHandler();
UNNotificationRequest *request = response.notification.request;
NSString *requestIdentifier = request.identifier;
if (requestIdentifier == nil)
{
return;
}
[database selectModelFromId:requestIdentifier withCompletionHandler:^(MyModel *modelObj,
NSError *errorOrNil)
{
if (modelObj != nil)
{
[self makeWebViewControllerForModeAndPutOnScreen:modelObj];
}
else
{
NSLog(@"error loading data for notification...");
}
}];
}
Okay so the view controller loaded uses WKWebView to load web content. Again every once in awhile the app crashes when I tap a notification. No crash report is ever generated for my app. I don't know why this is happening. Anybody experience anything similar and know what the issue could be? Thanks in advance.