Handle custom scheme URL

This commit is contained in:
SBiOSoftWhare 2020-12-18 18:22:46 +01:00
parent f8bbcc48b3
commit 58c811c85f
6 changed files with 44 additions and 5 deletions

View file

@ -52,6 +52,17 @@ final class BuildSettings: NSObject {
return keychainAccessGroup
}
static var applicationURLScheme: String? {
guard let urlTypes = Bundle.app.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [AnyObject],
let urlTypeDictionary = urlTypes.first as? [String: AnyObject],
let urlSchemes = urlTypeDictionary["CFBundleURLSchemes"] as? [AnyObject],
let externalURLScheme = urlSchemes.first as? String else {
return nil
}
return externalURLScheme
}
static var pushKitAppIdProd: String {
return baseBundleIdentifier + ".ios.voip.prod"
}

View file

@ -27,3 +27,5 @@ KEYCHAIN_ACCESS_GROUP = $(AppIdentifierPrefix)$(BASE_BUNDLE_IDENTIFIER).keychain
//Make Xcode 12 and fastlane(xcodebuild) happy while some pods are not updated
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64
APPLICATION_SCHEME = element

View file

@ -55,6 +55,13 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
func start() {
self.showSplitView(session: self.mainSession)
}
func open(url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// TODO: Implement an CustomURLSchemeParser.
// TODO: Handle element://connect for SSO redirect and check for a unique id to avoid security issue.
// As said in the Apple documentation be careful on security issues (see https://developer.apple.com/documentation/xcode/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app)
return false
}
// MARK: - Private methods

View file

@ -18,4 +18,6 @@ import Foundation
/// `AppCoordinatorType` is a protocol describing a Coordinator that handles application navigation flow.
protocol AppCoordinatorType: Coordinator {
func open(url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool
}

View file

@ -101,6 +101,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.legacyAppDelegate.applicationDidReceiveMemoryWarning(application)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return self.appCoordinator.open(url: url, options: options)
}
// MARK: User Activity Continuation
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

View file

@ -20,12 +20,30 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(BASE_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(APPLICATION_SCHEME)</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<true/>
<key>ITSEncryptionExportComplianceCode</key>
<string>d1dd539c-d21c-43e2-92e2-212c5269565c</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>http</string>
<string>https</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
@ -94,10 +112,5 @@
<string>$(BASE_BUNDLE_IDENTIFIER)</string>
<key>keychainAccessGroup</key>
<string>$(KEYCHAIN_ACCESS_GROUP)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>http</string>
<string>https</string>
</array>
</dict>
</plist>