Skip to content

Commit

Permalink
Added function for alert when reaching issue
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Holzschuch committed May 26, 2021
1 parent 9b47fc9 commit 96dfa00
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions shell_cmds_ios/open.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,35 @@ int open_main(int argc, char *argv[]) {

return openurl_main(argc, argv);
}

void display_alert(NSString* title, NSString* message) {
dispatch_async(dispatch_get_main_queue(), ^{

UIWindow *window = [UIApplication sharedApplication].keyWindow;

if (!window) {
return;
}

UIViewController *topController = window.rootViewController;

while (topController.presentedViewController) {
topController = topController.presentedViewController;
}

if (topController == NULL) {
return;
}

UIAlertController* alert = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[topController presentViewController:alert animated:YES completion:nil];
});
return;
}

0 comments on commit 96dfa00

Please sign in to comment.