mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Merge branch 'feature/3811_hotfix_mdm_crash' into 'hotfix/v2.10.1'
MESSENGER-3811 hotfix 2.10.1 crash on mdm See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!231
This commit is contained in:
@@ -16,5 +16,5 @@
|
||||
//
|
||||
|
||||
// Version
|
||||
MARKETING_VERSION = 2.10.0
|
||||
MARKETING_VERSION = 2.10.1
|
||||
CURRENT_PROJECT_VERSION = 20220714163152
|
||||
|
||||
@@ -26,6 +26,18 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p>
|
||||
<b>Version 2.10.1</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Behobene Bugs</b>
|
||||
<ul>
|
||||
<li/>Crashfix bei MDM Config Übergabe
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>
|
||||
<b>Version 2.10.0</b>
|
||||
|
||||
@@ -78,6 +78,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
UISwitch.appearance().thumbTintColor = ThemeService.shared().theme.backgroundColor
|
||||
UISwitch.appearance().onTintColor = ThemeService.shared().theme.tintColor
|
||||
|
||||
// bwi: testing mdm config
|
||||
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
// let dict = ["home_server_url": ""]
|
||||
// UserDefaults.standard.setValue(dict, forKey: "com.apple.configuration.managed")
|
||||
// }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -4576,10 +4576,15 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
- (void) setupAppConfig
|
||||
{
|
||||
AppConfigService* service = [AppConfigService shared];
|
||||
service.completion = ^(BOOL success) {
|
||||
// bwi: logout when mdm config has changed but only when logged in and config server url is not the same then before
|
||||
service.completion = ^(BOOL success, NSString* serverUrl) {
|
||||
if( success) {
|
||||
[self logoutWithoutConfirmation:YES completion:nil];
|
||||
NSLog(@"New AppConfig");
|
||||
if ([[[MXKAccountManager sharedManager] accounts] count] > 0) {
|
||||
NSString *currentUrl = [[[self.mxSessions firstObject] matrixRestClient] homeserver];
|
||||
if (currentUrl != nil && ![serverUrl isEqualToString:currentUrl]) {
|
||||
[self logoutWithoutConfirmation:YES completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
[service registerForAppConfig];
|
||||
|
||||
@@ -44,13 +44,15 @@ extension UserDefaults
|
||||
|
||||
var appConfig = AppConfig()
|
||||
|
||||
var completion: ((Bool) -> Void)?
|
||||
var completion: ((Bool, String) -> Void)?
|
||||
|
||||
var configObserver: NSKeyValueObservation!
|
||||
|
||||
var session: MXSession?
|
||||
|
||||
var isAppConfig: Bool
|
||||
|
||||
var lastDictionary: [String: Any]?
|
||||
|
||||
private func loadAppConfig() {
|
||||
isAppConfig = false
|
||||
@@ -90,8 +92,24 @@ extension UserDefaults
|
||||
self.loadAppConfig()
|
||||
}
|
||||
|
||||
func registerForAppConfig() {
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
private func isSameConfig( dict: [String: Any]) -> Bool {
|
||||
if let lastDictionary = lastDictionary {
|
||||
if lastDictionary.count != dict.count {
|
||||
return false
|
||||
}
|
||||
if let newURl = dict[serverUrlKey] as? String, let oldURL = lastDictionary[serverUrlKey] as? String, newURl == oldURL {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func registerForAppConfig() {
|
||||
NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: OperationQueue.main) { [self] (note) in
|
||||
handleAppConfig()
|
||||
}
|
||||
@@ -99,43 +117,44 @@ extension UserDefaults
|
||||
|
||||
func handleAppConfig() {
|
||||
if let dict = UserDefaults.standard.dictionary(forKey: configKey) {
|
||||
var config = AppConfig()
|
||||
|
||||
if let serverUrl = dict[serverUrlKey] as? String {
|
||||
if serverUrl.count == 0 {
|
||||
config.serverUrl = nil
|
||||
} else if checkUrlSavety(serverUrl) {
|
||||
config.serverUrl = serverUrl
|
||||
// only compute if serverURL has not changed (this may need to be changed on Adminportal integration
|
||||
if !isSameConfig(dict: dict) {
|
||||
var config = AppConfig()
|
||||
|
||||
if let serverUrl = dict[serverUrlKey] as? String {
|
||||
if serverUrl.count == 0 {
|
||||
config.serverUrl = nil
|
||||
} else if checkUrlSavety(serverUrl) {
|
||||
config.serverUrl = serverUrl
|
||||
}
|
||||
}
|
||||
if let contentScannerUrl = dict[contentScannerKey] as? String {
|
||||
if checkUrlSavety(contentScannerUrl) {
|
||||
config.contentScannerUrl = contentScannerUrl
|
||||
}
|
||||
}
|
||||
if let pusherUrl = dict[pusherUrlKey] as? String {
|
||||
if checkUrlSavety(pusherUrl) {
|
||||
config.pusherUrl = pusherUrl
|
||||
}
|
||||
}
|
||||
if let permalinkUrl = dict[permalinkUrlKey] as? String {
|
||||
if checkUrlSavety(permalinkUrl) {
|
||||
config.permalinkUrl = permalinkUrl
|
||||
}
|
||||
}
|
||||
|
||||
// app config needs at least a valid server url
|
||||
if let serverUrl = config.serverUrl {
|
||||
isAppConfig = true
|
||||
appConfig = config
|
||||
lastDictionary = dict
|
||||
self.saveAppConfig()
|
||||
if let completion = self.completion {
|
||||
completion(true, serverUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
if let contentScannerUrl = dict[contentScannerKey] as? String {
|
||||
if checkUrlSavety(contentScannerUrl) {
|
||||
config.contentScannerUrl = contentScannerUrl
|
||||
}
|
||||
}
|
||||
if let pusherUrl = dict[pusherUrlKey] as? String {
|
||||
if checkUrlSavety(pusherUrl) {
|
||||
config.pusherUrl = pusherUrl
|
||||
}
|
||||
}
|
||||
if let permalinkUrl = dict[permalinkUrlKey] as? String {
|
||||
if checkUrlSavety(permalinkUrl) {
|
||||
config.permalinkUrl = permalinkUrl
|
||||
}
|
||||
}
|
||||
|
||||
// app config needs at least a valid server url
|
||||
isAppConfig = (config.serverUrl != nil)
|
||||
|
||||
if config != appConfig {
|
||||
appConfig = config
|
||||
self.saveAppConfig()
|
||||
if let completion = completion {
|
||||
completion(true)
|
||||
}
|
||||
}
|
||||
|
||||
UserDefaults.standard.removeObject(forKey: configKey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,4 +192,6 @@ extension UserDefaults
|
||||
return BWIBuildSettings.shared.clientPermalinkBaseUrl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ fileprivate struct Page: View {
|
||||
if success {
|
||||
self.showAlertIfNeeded()
|
||||
} else {
|
||||
|
||||
buttonCallback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user