Fixed issue where urls without query parameters caused the app to crash on deeplink received

This commit is contained in:
Tobias Reski 2021-11-29 14:33:48 +01:00
parent b0c0929253
commit 26c4439841
3 changed files with 30 additions and 23 deletions

View file

@ -259,17 +259,19 @@ namespace TINK
protected override void OnAppLinkRequestReceived(Uri uri) protected override void OnAppLinkRequestReceived(Uri uri)
{ {
base.OnAppLinkRequestReceived(uri); base.OnAppLinkRequestReceived(uri);
// TODO: Adjust to correct host
if (uri.Host.ToLower() == "sharee.bike") if (uri.Host.ToLower() == "sharee.bike")
{ {
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51 // Input e.g. sharee.bike/sharee?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray(); Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query if (uri.Query.Length > 0)
.Substring(1) {
.Split("&") Dictionary<string, string> queryDict = uri.Query
.Select(query => query.Split('=')) .Substring(1)
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault()); .Split("&")
// segments == ["sharee", "lastenrad"] .Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
}
// segments == ["sharee"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}] // queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput // => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it // If no custom navigation is configured, the app just opens as if the user opened it

View file

@ -259,17 +259,19 @@ namespace TINK
protected override void OnAppLinkRequestReceived(Uri uri) protected override void OnAppLinkRequestReceived(Uri uri)
{ {
base.OnAppLinkRequestReceived(uri); base.OnAppLinkRequestReceived(uri);
// TODO: Adjust to correct host
if (uri.Host.ToLower() == "sharee.bike") if (uri.Host.ToLower() == "sharee.bike")
{ {
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51 // Input e.g. sharee.bike/sharee/?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray(); Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query if (uri.Query.Length > 0)
.Substring(1) {
.Split("&") Dictionary<string, string> queryDict = uri.Query
.Select(query => query.Split('=')) .Substring(1)
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault()); .Split("&")
// segments == ["sharee", "lastenrad"] .Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
}
// segments == ["sharee"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}] // queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput // => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it // If no custom navigation is configured, the app just opens as if the user opened it

View file

@ -261,14 +261,17 @@ namespace TINK
base.OnAppLinkRequestReceived(uri); base.OnAppLinkRequestReceived(uri);
if (uri.Host.ToLower() == "sharee.bike") if (uri.Host.ToLower() == "sharee.bike")
{ {
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51 // Input e.g. sharee.bike/sharee/?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray(); Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query if (uri.Query.Length > 0)
.Substring(1) {
.Split("&") Dictionary<string, string> queryDict = uri.Query
.Select(query => query.Split('=')) .Substring(1)
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault()); .Split("&")
// segments == ["sharee", "lastenrad"] .Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
}
// segments == ["sharee"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}] // queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput // => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it // If no custom navigation is configured, the app just opens as if the user opened it