NCManageEndToEndEncryption.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. //
  2. // NCManageEndToEndEncryption.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 13/10/17.
  6. // Copyright © 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "NCManageEndToEndEncryption.h"
  24. #import "AppDelegate.h"
  25. #import "CCNetworking.h"
  26. #import "NCBridgeSwift.h"
  27. @interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate>
  28. {
  29. AppDelegate *appDelegate;
  30. NSUInteger _failedAttempts;
  31. NSDate *_lockUntilDate;
  32. }
  33. @end
  34. @implementation NCManageEndToEndEncryption
  35. - (void)initializeForm
  36. {
  37. XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_e2e_settings_", nil)];
  38. XLFormSectionDescriptor *section;
  39. XLFormRowDescriptor *row;
  40. tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
  41. if (capabilities.endToEndEncryption == NO) {
  42. // Section SERVICE NOT AVAILABLE -------------------------------------------------
  43. section = [XLFormSectionDescriptor formSection];
  44. [form addFormSection:section];
  45. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"serviceActivated" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_e2e_settings_not_available_", nil)];
  46. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  47. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"closeCircle"] width:50 height:50 color:[UIColor redColor]] forKey:@"imageView.image"];
  48. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  49. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  50. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  51. [section addFormRow:row];
  52. self.form = form;
  53. return;
  54. }
  55. if ([CCUtility isEndToEndEnabled:appDelegate.activeAccount]) {
  56. // Section SERVICE ACTIVATED -------------------------------------------------
  57. section = [XLFormSectionDescriptor formSection];
  58. [form addFormSection:section];
  59. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"serviceActivated" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_e2e_settings_activated_", nil)];
  60. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  61. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"selectFull"] width:50 height:50 color:[UIColor greenColor]] forKey:@"imageView.image"];
  62. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  63. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  64. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  65. [section addFormRow:row];
  66. // Section PASSPHRASE -------------------------------------------------
  67. section = [XLFormSectionDescriptor formSection];
  68. [form addFormSection:section];
  69. // Read Passphrase
  70. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"readPassphrase" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
  71. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  72. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"e2eReadPassphrase"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  73. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  74. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  75. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  76. row.action.formSelector = @selector(readPassphrase:);
  77. [section addFormRow:row];
  78. // Section DELETE -------------------------------------------------
  79. section = [XLFormSectionDescriptor formSection];
  80. [form addFormSection:section];
  81. // remove locally Encryption
  82. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removeLocallyEncryption" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_remove_", nil)];
  83. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  84. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"lock"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  85. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  86. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  87. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  88. row.action.formSelector = @selector(removeLocallyEncryption:);
  89. [section addFormRow:row];
  90. } else {
  91. // Section START E2E -------------------------------------------------
  92. section = [XLFormSectionDescriptor formSection];
  93. [form addFormSection:section];
  94. // Start e2e
  95. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"startE2E" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_start_", nil)];
  96. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  97. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  98. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  99. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  100. row.action.formSelector = @selector(startE2E:);
  101. [section addFormRow:row];
  102. }
  103. #ifdef DEBUG
  104. // Section DELETE KEYS -------------------------------------------------
  105. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"Delete server keys ", nil)];
  106. [form addFormSection:section];
  107. // Delete publicKey
  108. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePublicKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"Delete PublicKey", nil)];
  109. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  110. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  111. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  112. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  113. row.action.formSelector = @selector(deletePublicKey:);
  114. [section addFormRow:row];
  115. // Delete privateKey
  116. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deletePrivateKey" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"Delete PrivateKey", nil)];
  117. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  118. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  119. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  120. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  121. row.action.formSelector = @selector(deletePrivateKey:);
  122. [section addFormRow:row];
  123. #endif
  124. self.form = form;
  125. }
  126. - (void)viewDidLoad
  127. {
  128. [super viewDidLoad];
  129. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  130. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  131. [self initializeForm];
  132. // E2EE
  133. self.endToEndInitialize = [NCEndToEndInitialize new];
  134. self.endToEndInitialize.delegate = self;
  135. }
  136. - (void)viewWillAppear:(BOOL)animated
  137. {
  138. [super viewWillAppear:animated];
  139. self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
  140. self.tableView.showsVerticalScrollIndicator = NO;
  141. self.tableView.separatorColor = NCBrandColor.sharedInstance.separator;
  142. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  143. [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
  144. }
  145. - (void)changeTheming
  146. {
  147. [appDelegate changeTheming:self tableView:self.tableView collectionView:nil];
  148. [self initializeForm];
  149. }
  150. #pragma --------------------------------------------------------------------------------------------
  151. #pragma mark === Action ===
  152. #pragma --------------------------------------------------------------------------------------------
  153. - (void)startE2E:(XLFormRowDescriptor *)sender
  154. {
  155. [self deselectFormRow:sender];
  156. if ([[CCUtility getBlockCode] length]) {
  157. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  158. viewController.delegate = self;
  159. viewController.fromType = CCBKPasscodeFromStartEncryption;
  160. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  161. if ([CCUtility getSimplyBlockCode]) {
  162. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  163. viewController.passcodeInputView.maximumLength = 6;
  164. } else {
  165. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  166. viewController.passcodeInputView.maximumLength = 64;
  167. }
  168. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  169. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  170. viewController.touchIDManager = touchIDManager;
  171. viewController.title = NSLocalizedString(@"_e2e_settings_start_", nil);
  172. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  173. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  174. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  175. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  176. [self presentViewController:navigationController animated:YES completion:nil];
  177. } else {
  178. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  179. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  180. }];
  181. [alertController addAction:okAction];
  182. [self presentViewController:alertController animated:YES completion:nil];
  183. }
  184. }
  185. - (void)readPassphrase:(XLFormRowDescriptor *)sender
  186. {
  187. [self deselectFormRow:sender];
  188. if ([[CCUtility getBlockCode] length]) {
  189. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  190. viewController.delegate = self;
  191. viewController.fromType = CCBKPasscodeFromCheckPassphrase;
  192. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  193. if ([CCUtility getSimplyBlockCode]) {
  194. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  195. viewController.passcodeInputView.maximumLength = 6;
  196. } else {
  197. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  198. viewController.passcodeInputView.maximumLength = 64;
  199. }
  200. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  201. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  202. viewController.touchIDManager = touchIDManager;
  203. viewController.title = NSLocalizedString(@"_e2e_settings_read_passphrase_", nil);
  204. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  205. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  206. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  207. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  208. [self presentViewController:navigationController animated:YES completion:nil];
  209. } else {
  210. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  211. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  212. }];
  213. [alertController addAction:okAction];
  214. [self presentViewController:alertController animated:YES completion:nil];
  215. }
  216. }
  217. - (void)removeLocallyEncryption:(XLFormRowDescriptor *)sender
  218. {
  219. [self deselectFormRow:sender];
  220. if ([[CCUtility getBlockCode] length]) {
  221. CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
  222. viewController.delegate = self;
  223. viewController.fromType = CCBKPasscodeFromRemoveEncryption;
  224. viewController.type = BKPasscodeViewControllerCheckPasscodeType;
  225. if ([CCUtility getSimplyBlockCode]) {
  226. viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
  227. viewController.passcodeInputView.maximumLength = 6;
  228. } else {
  229. viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
  230. viewController.passcodeInputView.maximumLength = 64;
  231. }
  232. BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
  233. touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
  234. viewController.touchIDManager = touchIDManager;
  235. viewController.title = NSLocalizedString(@"_e2e_settings_remove_", nil);
  236. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
  237. viewController.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
  238. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  239. navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
  240. [self presentViewController:navigationController animated:YES completion:nil];
  241. } else {
  242. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
  243. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  244. }];
  245. [alertController addAction:okAction];
  246. [self presentViewController:alertController animated:YES completion:nil];
  247. }
  248. }
  249. - (void)deletePublicKey:(XLFormRowDescriptor *)sender
  250. {
  251. [self deselectFormRow:sender];
  252. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPublicKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  253. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  254. [appDelegate messageNotification:@"E2E delete publicKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  255. } else {
  256. [appDelegate messageNotification:@"E2E delete publicKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  257. }
  258. }];
  259. }
  260. - (void)deletePrivateKey:(XLFormRowDescriptor *)sender
  261. {
  262. [self deselectFormRow:sender];
  263. [[NCNetworkingEndToEnd sharedManager] deleteEndToEndPrivateKeyWithAccount:appDelegate.activeAccount completion:^(NSString *account, NSString *message, NSInteger errorCode) {
  264. if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
  265. [appDelegate messageNotification:@"E2E delete privateKey" description:@"Success" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess errorCode:0];
  266. } else {
  267. [appDelegate messageNotification:@"E2E delete privateKey" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
  268. }
  269. }];
  270. }
  271. #pragma --------------------------------------------------------------------------------------------
  272. #pragma mark === Delegate ===
  273. #pragma --------------------------------------------------------------------------------------------
  274. - (void)endToEndInitializeSuccess
  275. {
  276. // Reload All Datasource
  277. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
  278. [self initializeForm];
  279. }
  280. #pragma --------------------------------------------------------------------------------------------
  281. #pragma mark === BKPasscodeViewController ===
  282. #pragma --------------------------------------------------------------------------------------------
  283. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(CCBKPasscode *)aViewController
  284. {
  285. return _failedAttempts;
  286. }
  287. - (NSDate *)passcodeViewControllerLockUntilDate:(CCBKPasscode *)aViewController
  288. {
  289. return _lockUntilDate;
  290. }
  291. - (void)passcodeViewCloseButtonPressed:(id)sender
  292. {
  293. [self dismissViewControllerAnimated:YES completion:nil];
  294. }
  295. - (void)passcodeViewController:(CCBKPasscode *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void (^)(BOOL))aResultHandler
  296. {
  297. if ([aPasscode isEqualToString:[CCUtility getBlockCode]]) {
  298. _lockUntilDate = nil;
  299. _failedAttempts = 0;
  300. aResultHandler(YES);
  301. } else
  302. aResultHandler(NO);
  303. }
  304. - (void)passcodeViewController:(CCBKPasscode *)aViewController didFinishWithPasscode:(NSString *)aPasscode
  305. {
  306. [aViewController dismissViewControllerAnimated:YES completion:nil];
  307. if (aViewController.fromType == CCBKPasscodeFromStartEncryption) {
  308. [self.endToEndInitialize initEndToEndEncryption];
  309. }
  310. if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
  311. NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:appDelegate.activeAccount];
  312. NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
  313. NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
  314. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  315. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  316. }];
  317. [alertController addAction:okAction];
  318. [self presentViewController:alertController animated:YES completion:nil];
  319. }
  320. if (aViewController.fromType == CCBKPasscodeFromRemoveEncryption) {
  321. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
  322. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  323. [CCUtility clearAllKeysEndToEnd:appDelegate.activeAccount];
  324. [self initializeForm];
  325. }];
  326. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  327. NSLog(@"[LOG] Cancel action");
  328. }];
  329. [alertController addAction:okAction];
  330. [alertController addAction:cancelAction];
  331. [self presentViewController:alertController animated:YES completion:nil];
  332. }
  333. }
  334. @end