Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open custom server via custom url scheme #5392

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -31,15 +31,15 @@ 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)

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
Expand Down Expand Up @@ -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
```


Expand All @@ -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).
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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="[email protected]"`
```
export APPLE_ID="[email protected]"
```

To make an App Store release you can directly execute this command:

`bundle exec fastlane app_store build_number:<your_build_number>`
```
bundle exec fastlane app_store build_number:<your_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 <tag or branch>`
```
./buildRelease.sh <tag or branch>
```
4 changes: 4 additions & 0 deletions Riot/Modules/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/DeepLink/CustomSchemeURLConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
24 changes: 24 additions & 0 deletions Riot/Modules/DeepLink/CustomSchemeURLParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
}
1 change: 1 addition & 0 deletions Riot/Modules/DeepLink/DeepLinkOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions changelog.d/5391.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Open custom server from custom url scheme