AppDelegate.swift 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // AppDelegate.swift
  3. // DemoApp
  4. //
  5. // Created by wesley on 2021/6/21.
  6. //
  7. import ImSDK_Plus
  8. import TUIRoomKit
  9. import UIKit
  10. import TUIRoomKit
  11. import TIMPush
  12. #if DEBUG
  13. let offlinePushBusinessID: Int32 = 0
  14. #else
  15. let offlinePushBusinessID: Int32 = 0
  16. #endif
  17. @main
  18. class AppDelegate: UIResponder, UIApplicationDelegate {
  19. var window: UIWindow?
  20. var orientation: UIInterfaceOrientationMask = .allButUpsideDown
  21. func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
  22. return orientation
  23. }
  24. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  25. if #available(iOS 13, *) {
  26. } else {
  27. window = UIWindow(frame: UIScreen.main.bounds)
  28. window?.backgroundColor = UIColor.white
  29. let loginVC = TRTCLoginViewController()
  30. let nav = RoomNavigationController(rootViewController: loginVC)
  31. window?.rootViewController = nav
  32. window?.makeKeyAndVisible()
  33. }
  34. return true
  35. }
  36. // MARK: UISceneSession Lifecycle
  37. @available(iOS 13.0, *)
  38. func application(_ application: UIApplication,
  39. configurationForConnecting connectingSceneSession: UISceneSession,
  40. options: UIScene.ConnectionOptions) -> UISceneConfiguration {
  41. // Called when a new scene session is being created.
  42. // Use this method to select a configuration to create the new scene with.
  43. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
  44. }
  45. @available(iOS 13.0, *)
  46. func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
  47. }
  48. }
  49. extension AppDelegate: TIMPushDelegate {
  50. func businessID() -> Int32 {
  51. return offlinePushBusinessID
  52. }
  53. func onRemoteNotificationReceived(_ notice: String?) -> Bool {
  54. guard let notice = notice else { return false }
  55. guard let dict = notice.convertToDic() else { return false }
  56. guard let roomId = dict["RoomId"] as? String else { return false }
  57. guard let notificationType = dict["NotificationType"] as? String else { return false }
  58. if V2TIMManager.sharedInstance().getLoginStatus() == .STATUS_LOGINED {
  59. switch notificationType {
  60. case "conference_will_start":
  61. AppUtils.shared.showConferenceMainViewController(roomId: roomId)
  62. case "conference_invitation":
  63. InvitationObserverService.shared.show(extString: notice)
  64. default:
  65. break
  66. }
  67. }
  68. return true
  69. }
  70. }