From 9a45e400d7ceb302532c08b49451285a835a6ab6 Mon Sep 17 00:00:00 2001 From: Martin Delille Date: Sun, 16 Jan 2022 22:52:01 +0100 Subject: [PATCH 1/2] Make github markdown command copiable --- INSTALL.md | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 667f308f43..fd401de1ff 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,7 +21,7 @@ If you do not want to grant the ruby package manager, [RubyGems](https://rubygem To install CocoaPods you can grab the right version by using `bundler` (recommended) or you can directly install it with RubyGems: ``` -$ gem install cocoapods +gem install cocoapods ``` In the last case please ensure that you are using the same version as indicated at the end of the `Podfile.lock` file. @@ -31,7 +31,7 @@ In the last case please ensure that you are using the same version as indicated You can directly install XcodeGen with [Homebrew](https://brew.sh) or RubyGems: ``` -$ brew install xcodegen +brew install xcodegen ``` ### Install bundler (optional) @@ -39,7 +39,7 @@ $ brew install xcodegen By using `bundler` you will ensure to use the right versions of build tools used to build and deliver the project. You can find dependency definitions in the `Gemfile`. To install `bundler`: ``` -$ gem install bundler +gem install bundler ``` ## Choose Matrix SDKs version to build @@ -89,7 +89,7 @@ More advanced build configuration can be found in the `project.yml` file and eac In order to get rid of git conflicts, the `Riot.xcodeproj` is not pushed into the git repository anymore but generated using `XcodeGen`. To generate the `xcodeproj` file simply run the following command line from the root folder : ``` -$ xcodegen +xcodegen ``` @@ -100,14 +100,14 @@ Then, before opening the Element Xcode workspace, you need to install dependenci To be sure to use the right CocoaPods version you can use `bundler`: ``` -$ bundle install -$ bundle exec pod install +bundle install +bundle exec pod install ``` Or if you prefer to use directly CocoaPods: ``` -$ pod install +pod install ``` This will load all dependencies for the Element source code, including [MatrixSDK](https://github.com/matrix-org/matrix-ios-sdk). @@ -118,7 +118,7 @@ This will load all dependencies for the Element source code, including [MatrixSD Then, open `Riot.xcworkspace` with Xcode. ``` -$ open Riot.xcworkspace +open Riot.xcworkspace ``` **Note**: If you have multiple Xcode versions installed don't forget to use the right version of Command Line Tools when you are building the app. To check the Command Line Tools version go to `Xcode > Preferences > Locations > Command Line Tools` and check that the displayed version match your Xcode version. @@ -129,7 +129,7 @@ $ open Riot.xcworkspace If you want to generate the project easily and quickly, there is a local script called `setup_project.sh` that creates the `xcodeproj` and `xcworkspace` with all source files and dependencies with commands described before. It automatically selects the right dependencies based on your local Git branch or your Podfile local modifications. All you have to do is to go in the project root folder and run the script: ``` -$ ./setup_project.sh +./setup_project.sh ``` ## Generate IPA @@ -156,16 +156,24 @@ For other times: Before executing the release command you need to export your Apple ID in environment variables: -`export APPLE_ID="foo.bar@apple.com"` +``` +export APPLE_ID="foo.bar@apple.com" +``` To make an App Store release you can directly execute this command: -`bundle exec fastlane app_store build_number:` +``` +bundle exec fastlane app_store build_number: +``` Or you can use the wrapper script located at `/Tools/Release/buildRelease.sh`. For that go to the `Release` folder: -`$ cd ./Tools/Release/` +``` +cd ./Tools/Release/ +``` And then indicate a branch or a tag like this: -`$ ./buildRelease.sh ` +``` +./buildRelease.sh +``` From f8c428d45bb41128995c1a7402ee8504f17ec364 Mon Sep 17 00:00:00 2001 From: Martin Delille Date: Sun, 16 Jan 2022 23:17:57 +0100 Subject: [PATCH 2/2] First draft for custom url: catch url --- Riot/Modules/Application/AppCoordinator.swift | 4 ++++ .../DeepLink/CustomSchemeURLConstants.swift | 3 +++ .../DeepLink/CustomSchemeURLParser.swift | 24 +++++++++++++++++++ Riot/Modules/DeepLink/DeepLinkOption.swift | 1 + changelog.d/5391.feature | 1 + 5 files changed, 33 insertions(+) create mode 100644 changelog.d/5391.feature diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift index d60faf924d..3d3a2fb896 100755 --- a/Riot/Modules/Application/AppCoordinator.swift +++ b/Riot/Modules/Application/AppCoordinator.swift @@ -173,6 +173,10 @@ final class AppCoordinator: NSObject, AppCoordinatorType { switch deepLinkOption { case .connect(let loginToken, let transactionId): canOpenLink = self.legacyAppDelegate.continueSSOLogin(withToken: loginToken, txnId: transactionId) + case .customServer(let customServerUrl, let autoSignIn): + MXLog.debug("TODO handle url: \(customServerUrl)") + MXLog.debug("TODO handle auto sign in: \(autoSignIn ? "yes":"no")") + canOpenLink = false } return canOpenLink diff --git a/Riot/Modules/DeepLink/CustomSchemeURLConstants.swift b/Riot/Modules/DeepLink/CustomSchemeURLConstants.swift index 6393592f2c..a86ae4601c 100644 --- a/Riot/Modules/DeepLink/CustomSchemeURLConstants.swift +++ b/Riot/Modules/DeepLink/CustomSchemeURLConstants.swift @@ -20,9 +20,12 @@ enum CustomSchemeURLConstants { enum Parameters { static let transactionId = "transaction_id" + static let customServerUrl = "custom_server_url" + static let autoSignIn = "auto_sign_in" } enum Hosts { static let connect = "connect" + static let customServer = "custom_server" } } diff --git a/Riot/Modules/DeepLink/CustomSchemeURLParser.swift b/Riot/Modules/DeepLink/CustomSchemeURLParser.swift index 5da141a30a..b369761fe3 100644 --- a/Riot/Modules/DeepLink/CustomSchemeURLParser.swift +++ b/Riot/Modules/DeepLink/CustomSchemeURLParser.swift @@ -43,6 +43,12 @@ class CustomSchemeURLParser { } else { throw CustomSchemeURLParserError.invalidParameters } + case CustomSchemeURLConstants.Hosts.customServer: + if let deepLinkOpt = self.buildDeepLinkCustomServer(from: urlComponents) { + deepLinkOption = deepLinkOpt + } else { + throw CustomSchemeURLParserError.invalidParameters + } default: throw CustomSchemeURLParserError.unknownHost } @@ -65,4 +71,22 @@ class CustomSchemeURLParser { return DeepLinkOption.connect(loginToken, txnId) } + + private func buildDeepLinkCustomServer(from urlComponents: URLComponents) -> DeepLinkOption? { + guard let queryItems = urlComponents.queryItems, queryItems.isEmpty == false else { + return nil + } + + guard let customServerUrl = urlComponents.vc_getQueryItemValue(for: CustomSchemeURLConstants.Parameters.customServerUrl) else { + return nil + } + + var autoSignIn=false + if let autoSignInValue = urlComponents.vc_getQueryItemValue(for: CustomSchemeURLConstants.Parameters.autoSignIn) { + autoSignIn=(autoSignInValue=="yes") + } + + + return DeepLinkOption.customServer(customServerUrl, autoSignIn: autoSignIn) + } } diff --git a/Riot/Modules/DeepLink/DeepLinkOption.swift b/Riot/Modules/DeepLink/DeepLinkOption.swift index 1799be5888..57f0a44c8e 100644 --- a/Riot/Modules/DeepLink/DeepLinkOption.swift +++ b/Riot/Modules/DeepLink/DeepLinkOption.swift @@ -21,4 +21,5 @@ enum DeepLinkOption { /// Used for SSO callback only when VoiceOver is enabled case connect(_ loginToken: String, _ transactionId: String) + case customServer(_ customServerUrl: String, autoSignIn: Bool) } diff --git a/changelog.d/5391.feature b/changelog.d/5391.feature new file mode 100644 index 0000000000..6bceead426 --- /dev/null +++ b/changelog.d/5391.feature @@ -0,0 +1 @@ +Open custom server from custom url scheme