Files
yingmeng-ios-switf/yinmeng-ios/AppDelegate.swift

78 lines
2.3 KiB
Swift
Raw Normal View History

2024-02-21 21:30:13 +08:00
//
// AppDelegate.swift
// yinmeng-ios
//
2024-03-05 14:04:09 +08:00
// Created by yinmeng on 2024/1/30.
2024-02-21 21:30:13 +08:00
//
import UIKit
2024-02-24 13:49:51 +08:00
import DeviceKit
2024-02-25 12:53:56 +08:00
import NSObject_Rx
2024-02-29 23:49:12 +08:00
import NIMSDK
2024-02-21 21:30:13 +08:00
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.applicationIconBadgeNumber = 0
self.window = UIWindow.init(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
2024-02-29 00:42:41 +08:00
self.window?.rootViewController = BaseNavigationViewController(rootViewController:AuthLaunchVC())
2024-02-29 23:49:12 +08:00
loadNIMSDK()
2024-02-25 12:53:56 +08:00
loginStateListener()
2024-02-29 23:49:12 +08:00
2024-02-21 21:30:13 +08:00
return true
}
2024-02-24 13:49:51 +08:00
2024-02-25 12:53:56 +08:00
private func loginStateListener() {
2024-02-25 23:11:02 +08:00
AuthViewModel.authVM.appClientConfig()
///
AuthViewModel.authVM.checkUserIsLogin()
2024-02-25 12:53:56 +08:00
AuthViewModel.authVM.loginSuccess.subscribe(onNext: { result in
print("是否登录成功\(result)")
if result == true {
///tabbar
2024-02-25 13:10:44 +08:00
self.window?.rootViewController = BaseTabBarViewController()
2024-03-01 20:37:00 +08:00
let uid = AuthManager.userUid
if uid > 0 {
2024-02-25 23:11:02 +08:00
UserViewModel.userVM.getUserInfo(uid: uid)
}
2024-02-29 23:49:12 +08:00
if NIMSDK.shared().loginManager.isLogined() == false {
if let uid = LoginTokenConfig.config.getAccountInfo()?.uid, let token = LoginTokenConfig.config.getAccountInfo()?.netEaseToken {
NIMSDK.shared().loginManager.login("\(uid)", token: token) { error in
print("aaa")
}
} else {
///
self.window?.rootViewController = BaseNavigationViewController(rootViewController:AuthLaunchVC())
}
}
2024-02-25 12:53:56 +08:00
} else {
///
2024-02-29 00:42:41 +08:00
self.window?.rootViewController = BaseNavigationViewController(rootViewController:AuthLaunchVC())
2024-02-25 12:53:56 +08:00
}
}).disposed(by: rx.disposeBag)
2024-02-25 23:11:02 +08:00
2024-03-01 20:37:00 +08:00
UserViewModel.userVM.selfInfo.subscribe(onNext: { result in
2024-02-29 23:49:12 +08:00
if result.nick?.count ?? 0 <= 0 || result.avatar?.count ?? 0 <= 0 {
let fillVC = AuthFillDataVC()
fillVC.modalPresentationStyle = .fullScreen
2024-04-03 20:06:02 +08:00
self.window?.rootViewController = fillVC
2024-02-29 23:49:12 +08:00
}
}).disposed(by: rx.disposeBag)
}
2024-02-25 12:53:56 +08:00
2024-02-29 23:49:12 +08:00
private func loadNIMSDK() {
let opt = NIMSDKOption(appKey: AppKeys.nimAppid)
opt.apnsCername = "yinmeng_anps"
NIMSDK.shared().register(with: opt)
2024-03-23 18:21:29 +08:00
NIMCustomObject.registerCustomDecoder(YinCustomAttachmentCoding())
2024-02-25 12:53:56 +08:00
}
2024-02-21 21:30:13 +08:00
}
2024-02-24 13:49:51 +08:00