From 3f5099d29a4ea47f6f75f4d5f2d5a06227da99e4 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 20 Nov 2019 20:23:39 +0800 Subject: [PATCH] feat:add alert for iOS --- iOS/Pod/Classes/Plugin/DoricModalPlugin.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/iOS/Pod/Classes/Plugin/DoricModalPlugin.m b/iOS/Pod/Classes/Plugin/DoricModalPlugin.m index b13f2734..3f7eb212 100644 --- a/iOS/Pod/Classes/Plugin/DoricModalPlugin.m +++ b/iOS/Pod/Classes/Plugin/DoricModalPlugin.m @@ -36,4 +36,19 @@ - (void)toast:(NSDictionary *)dic withPromise:(DoricPromise *)promise { }); } +- (void)alert:(NSDictionary *)dic withPromise:(DoricPromise *)promise { + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle:dic[@"title"] + message:dic[@"msg"] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *action = [UIAlertAction actionWithTitle:dic[@"okLabel"] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [promise resolve:nil]; + }]; + [alert addAction:action]; + UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController; + [vc presentViewController:alert animated:YES completion:nil]; + }); +} @end