SettingController.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // SettingController.m
  3. // AJPushDemo
  4. //
  5. // Created by Black on 2021/2/4.
  6. // Copyright © 2018 anji-plus 安吉加加信息技术有限公司 http://www.anji-plus.com. All rights reserved.
  7. //
  8. #import "SettingController.h"
  9. #import "SettingManager.h"
  10. @interface SettingController ()
  11. @property (weak, nonatomic) IBOutlet UITextField *jpushText;
  12. @property (weak, nonatomic) IBOutlet UITextField *appspKeyText;
  13. @property (weak, nonatomic) IBOutlet UITextField *appspUrlTxt;
  14. @property (weak, nonatomic) IBOutlet UITextField *secretKeyText;
  15. @end
  16. @implementation SettingController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.title = @"配置中心";
  20. self.jpushText.text = [SettingManager getJPushKey];
  21. self.appspKeyText.text = [SettingManager getAppSpKey];
  22. self.appspUrlTxt.text = [SettingManager getAppSpUrl];
  23. self.secretKeyText.text = [SettingManager getAppSpSecretKey];
  24. }
  25. - (IBAction)saveBtnClick:(id)sender {
  26. [self.view endEditing:YES];
  27. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"是否确认修改" message:nil preferredStyle:UIAlertControllerStyleAlert];
  28. UIAlertAction *conform = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  29. //处理跳转
  30. [self saveConfigure];
  31. }];
  32. UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  33. }];
  34. [alert addAction:conform];
  35. [alert addAction:cancel];
  36. [self presentViewController:alert animated:YES completion:nil];
  37. }
  38. - (void)saveConfigure {
  39. [SettingManager setJPushKey:self.jpushText.text];
  40. [SettingManager setAppSpKey:self.appspKeyText.text];
  41. [SettingManager setAppSpUrl:self.appspUrlTxt.text];
  42. [SettingManager setAppSpSecretKey:self.secretKeyText.text];
  43. NSLog(@"jpushKey: %@", self.jpushText.text);
  44. NSLog(@"appspKey: %@", self.appspKeyText.text);
  45. NSLog(@"appspUrl: %@", self.appspUrlTxt.text);
  46. NSLog(@"secretKey: %@", self.secretKeyText.text);
  47. dispatch_queue_t queue = dispatch_get_main_queue();
  48. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), queue, ^{
  49. [self.navigationController popViewControllerAnimated:YES];
  50. });
  51. }
  52. //屏幕手势事件
  53. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  54. [self.view endEditing:YES];
  55. }
  56. - (void)dealloc {
  57. NSLog(@"SettingController dealloc");
  58. }
  59. @end