diff --git a/Monal/Monal.xcodeproj/project.pbxproj b/Monal/Monal.xcodeproj/project.pbxproj index beea7e3..349312e 100644 --- a/Monal/Monal.xcodeproj/project.pbxproj +++ b/Monal/Monal.xcodeproj/project.pbxproj @@ -3736,6 +3736,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3826,6 +3827,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3918,6 +3920,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -4010,6 +4013,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -4102,6 +4106,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -4194,6 +4199,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS"; PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Monal/another.im/AnotherIMApp.swift b/Monal/another.im/AnotherIMApp.swift index 2fc2aee..d0add7f 100644 --- a/Monal/another.im/AnotherIMApp.swift +++ b/Monal/another.im/AnotherIMApp.swift @@ -1,3 +1,4 @@ +import monalxmpp import SwiftUI @main @@ -5,6 +6,10 @@ struct AnotherIMApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @StateObject var wrapper = MonalXmppWrapper() + init() { + DDLog.add(DDOSLogger.sharedInstance, with: .all) + } + var body: some Scene { WindowGroup { RootView() @@ -13,4 +18,9 @@ struct AnotherIMApp: App { } } -class AppDelegate: NSObject, UIApplicationDelegate {} +class AppDelegate: UIResponder, UIApplicationDelegate { + func applicationWillEnterForeground(_: UIApplication) { + // let manager = MLXMPPManager.sharedInstance() + // manager.nowForegrounded() + } +} diff --git a/Monal/another.im/XMPP/MonalXmppWrapper.swift b/Monal/another.im/XMPP/MonalXmppWrapper.swift index 7f9c998..007363a 100644 --- a/Monal/another.im/XMPP/MonalXmppWrapper.swift +++ b/Monal/another.im/XMPP/MonalXmppWrapper.swift @@ -25,7 +25,8 @@ final class MonalXmppWrapper: ObservableObject { NotificationCenter.default.post(name: Notification.Name(kMonalRefresh), object: nil) // reconnect - xmpp.connectIfNecessary() + // xmpp.nowForegrounded() + // xmpp.connectIfNecessary() } deinit { @@ -85,12 +86,10 @@ private final class LoginTry { // Обработать кейс когда бесячий monalxmpp возвращает nil при попытке добавить тот же JID func tryLogin(_ login: String, _ password: String) async -> Bool { async let notify = await withCheckedContinuation { [weak self] continuation in - self?.successObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kMLResourceBoundNotice"), object: nil, queue: .main) { notification in - print(notification.debugDescription) + self?.successObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kMLResourceBoundNotice"), object: nil, queue: .main) { _ in continuation.resume(returning: true) } - self?.failureObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kXMPPError"), object: nil, queue: .main) { notification in - print(notification.debugDescription) + self?.failureObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kXMPPError"), object: nil, queue: .main) { _ in continuation.resume(returning: false) } } @@ -188,6 +187,8 @@ final class MonalChatWrapper: ObservableObject { self.contact = contact self.db = db self.xmpp = xmpp + + subscribe() } deinit {