I am making a today extension and I am trying to let it display an AlertController like so:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"AlertView" message:@"I am an AlertView" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
Sadly, it crashes on the first line with this error:
2016-02-18 11:53:46.311 App Scenes[17870:669107] *** Assertion failure in void _UIApplicationAssertForExtensionType(NSArray *__strong)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UIApplication.m:2446
2016-02-18 11:53:51.230 App Scenes[17870:669107] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Feature not available in extensions of type com.apple.widget-extension'
I am calling this code from the TodayViewController. Can anyone tell me why this code isn't working?
The error message tells you everything you need to know.
reason: 'Feature not available in extensions of type com.apple.widget-extension'
Apple obviously don't allow people to present alerts from today extensions, even if they did I can't imagine it being and enjoyable user experience.