mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-16 06:28:27 +02:00
Feature/3637 pusher url
This commit is contained in:
committed by
Arnfried Griesert
parent
3a6c5d5b9f
commit
12a982724f
@@ -200,7 +200,7 @@ class BWIBuildSettings: NSObject {
|
||||
var serverConfigDefaultHomeserverUrlString = ""
|
||||
var serverConfigDefaultIdentityServerUrlString = ""
|
||||
var serverConfigPreSelections = ["":""]
|
||||
var serverConfigSygnalAPIUrlString = ""
|
||||
var serverConfigSygnalAPIUrlString = "https://push-local/_matrix/push/v1/notify"
|
||||
|
||||
// Note: Set empty strings to hide the related entry in application settings
|
||||
var applicationCopyrightUrlString = "https://messenger.bwi.de/copyright"
|
||||
|
||||
@@ -1863,6 +1863,17 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
}
|
||||
|
||||
[self handleAppState];
|
||||
|
||||
// bwi: check if pusher url has changed and push needs to be enabled again
|
||||
PusherURLHelper* pusherHelper = [[PusherURLHelper alloc] init];
|
||||
if ([pusherHelper isChangedPusherURL]) {
|
||||
[pusherHelper savePusherURL];
|
||||
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
|
||||
if ( account ) {
|
||||
[self.pushNotificationService registerUserNotificationSettings];
|
||||
}
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
// Register an observer in order to handle new account
|
||||
|
||||
@@ -148,8 +148,6 @@ extension UserDefaults
|
||||
func pusherUrl() -> String {
|
||||
if let url = appConfig.pusherUrl {
|
||||
return url
|
||||
} else if let url = ServerURLHelper.shared.pusherUrl() {
|
||||
return url
|
||||
} else {
|
||||
return BWIBuildSettings.shared.serverConfigSygnalAPIUrlString
|
||||
}
|
||||
|
||||
41
bwi/PusherURL/PusherURLHelper.swift
Normal file
41
bwi/PusherURL/PusherURLHelper.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2022 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers class PusherURLHelper : NSObject {
|
||||
|
||||
// returns true if there is no pusherURL saved or when it has changed
|
||||
func isChangedPusherURL() -> Bool {
|
||||
let currentPushURL = AppConfigService.shared.pusherUrl()
|
||||
|
||||
guard let oldPusherURL = UserDefaults.standard.string(forKey: "BWIPusherURL") else {
|
||||
return true
|
||||
}
|
||||
|
||||
return oldPusherURL != currentPushURL
|
||||
}
|
||||
|
||||
func savePusherURL() {
|
||||
let currentPushURL = AppConfigService.shared.pusherUrl()
|
||||
|
||||
UserDefaults.standard.set(currentPushURL, forKey: "BWIPusherURL")
|
||||
UserDefaults.standard
|
||||
.synchronize()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,12 +49,11 @@ import Foundation
|
||||
for urlSet in urls {
|
||||
if let dict = urlSet as? Dictionary<String,String> {
|
||||
if let server = dict[serverUrlKey],
|
||||
let pusher = dict[pusherUrlKey],
|
||||
let flavor = dict[flavorUrlKey],
|
||||
let name = dict[nameKey],
|
||||
let permalink = dict[permalinkKey] ,
|
||||
let analytics = dict[analyticsKey] {
|
||||
serverSettings.append(ServerSetting(name:name, serverUrl: server, pusherUrl: pusher, flavor: flavor, permalink:permalink, analytics: analytics))
|
||||
serverSettings.append(ServerSetting(name:name, serverUrl: server, pusherUrl: "", flavor: flavor, permalink:permalink, analytics: analytics))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +88,7 @@ import Foundation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func pusherUrl() -> String? {
|
||||
if serverSettings.indices.contains(selectedIndex) {
|
||||
return serverSettings[selectedIndex].pusherUrl
|
||||
|
||||
Reference in New Issue
Block a user