feat:add alert for iOS

This commit is contained in:
pengfei.zhou 2019-11-20 20:23:39 +08:00
parent 9a6f2d7f9f
commit 3f5099d29a

View File

@ -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