Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #220 from NIFCLOUD-mbaas/fix/remove_ui_alert_view
Browse files Browse the repository at this point in the history
issue #136 warning deprecated UIAlertView on ios 10
  • Loading branch information
kobo0908 committed Sep 25, 2020
2 parents 73eef06 + 4c17879 commit 7abde91
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions NCMB/NCMBPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ + (void)handlePush:(NSDictionary *)userInfo{
NSString *message = nil;
NSString *cancelButtonTitle = @"Close";
NSString *actionButtonTitle = nil;
UIAlertView *alert = nil;
UIAlertController *alertController = nil;
if ([[dicAps objectForKey:@"alert"] isKindOfClass:[NSNull class]]) {
}else if ([[dicAps objectForKey:@"alert"] isKindOfClass:[NSString class]]) {
Expand All @@ -87,7 +86,6 @@ + (void)handlePush:(NSDictionary *)userInfo{
if ([dicParams objectForKey:@"action-loc-key"]) {
actionButtonTitle = NSLocalizedString([dicParams objectForKey:@"action-loc-key"], @"action-loc-key");
}
alert = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:cancelButtonTitle otherButtonTitles:actionButtonTitle,nil];
}

if ([dicAps objectForKey:@"sound"]) {
Expand Down Expand Up @@ -120,26 +118,17 @@ + (void)handlePush:(NSDictionary *)userInfo{
}
}

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0){
UIViewController *baseView = [UIApplication sharedApplication].keyWindow.rootViewController;
while (baseView.presentedViewController != nil && !baseView.presentedViewController.isBeingDismissed) {
baseView = baseView.presentedViewController;
}
alertController = [UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[baseView dismissViewControllerAnimated:YES completion:nil];
}]];
[baseView presentViewController:alertController animated:YES completion:nil];
} else {
alert = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:actionButtonTitle, nil];
[alert show];
UIViewController *baseView = [UIApplication sharedApplication].keyWindow.rootViewController;
while (baseView.presentedViewController != nil && !baseView.presentedViewController.isBeingDismissed) {
baseView = baseView.presentedViewController;
}
alertController = [UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[baseView dismissViewControllerAnimated:YES completion:nil];
}]];
[baseView presentViewController:alertController animated:YES completion:nil];
}

+ (void) handleRichPush:(NSDictionary *)userInfo {
Expand Down

0 comments on commit 7abde91

Please sign in to comment.