ViewController.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // ViewController.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by mac on 2024/4/10.
  6. //
  7. import UIKit
  8. class ViewController: UIViewController {
  9. override func viewDidLoad() {
  10. super.viewDidLoad()
  11. self.intoMain()
  12. }
  13. func intoMain() {
  14. QSLBaseManager.shared.initConfig()
  15. // 是否通过引导页
  16. let isShowGuideKey = UserDefaults.standard.bool(forKey: "isShowGuideKey")
  17. if !isShowGuideKey {
  18. // 引导页
  19. UserDefaults.standard.set(true, forKey: "isShowGuideKey")
  20. if let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {
  21. sceneDelegate.window?.rootViewController = QSLGuideController()
  22. sceneDelegate.window?.makeKeyAndVisible()
  23. }
  24. } else {
  25. UNUserNotificationCenter.current().requestAuthorization(
  26. options: [.alert, .sound, .badge]
  27. ) { granted, error in
  28. DispatchQueue.main.async {
  29. if granted {
  30. DispatchQueue.main.async {
  31. UIApplication.shared.registerForRemoteNotifications()
  32. }
  33. } else if let error = error {
  34. print("Error: \(error.localizedDescription)")
  35. }
  36. }
  37. }
  38. if(!QSLBaseManager.shared.isLoadG){
  39. QSLBaseManager.shared.initIDFA()
  40. }
  41. // 主页
  42. if let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {
  43. sceneDelegate.window?.rootViewController = CustomTabBarController()
  44. sceneDelegate.window?.makeKeyAndVisible()
  45. }
  46. }
  47. }
  48. // 用户协议跳转
  49. func agreementAction() {
  50. let vc = QSLWebViewController()
  51. vc.webUrl = QSLConfig.AppServiceAgreementLink
  52. vc.title = "用户协议"
  53. vc.isShowTop = true
  54. self.present(vc, animated: true)
  55. }
  56. // 隐私协议跳转
  57. func privacyAction() {
  58. let vc = QSLWebViewController()
  59. vc.webUrl = QSLConfig.AppPrivacyAgreementLink
  60. vc.title = "隐私政策"
  61. vc.isShowTop = true
  62. self.present(vc, animated: true)
  63. }
  64. }