Implemented deeplinking in android

This commit is contained in:
Tobias Reski 2021-11-19 10:35:26 +01:00
parent 950c50f218
commit d734d4e5e5
13 changed files with 12150 additions and 9637 deletions

View file

@ -191,6 +191,9 @@
<PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="117.6.0.2" />
<PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="117.0.1.1" />
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="117.2.1.1" />
<PackageReference Include="Xamarin.Forms.AppLinks">
<Version>5.0.0.2244</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Android" />

View file

@ -4,11 +4,28 @@ using Android.Content.PM;
using Android.OS;
using Android.Content;
using Java.Interop;
using Xamarin.Forms.Platform.Android.AppLinks;
using Firebase;
namespace TINK.Droid
{
[Activity (Label = "LastenradBayern", Icon = "@drawable/sharee", Theme="@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "https",
DataHost = "sharee.bike", // TODO: Adjust to correct domain
DataPathPrefix = "/",
AutoVerify = true)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "http",
DataHost = "sharee.bike", // TODO: Adjust to correct domain
DataPathPrefix = "/",
AutoVerify = true)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate (Bundle bundle)
{
@ -19,6 +36,9 @@ namespace TINK.Droid
global::Xamarin.Forms.Forms.Init (this, bundle);
FirebaseApp.InitializeApp(this);
AndroidAppLinks.Init(this);
// Initialize xamarin.essentials, see https://docs.microsoft.com/en-us/xamarin/essentials/get-started?tabs=macos%2Candroid.
Xamarin.Essentials.Platform.Init(this, bundle);

File diff suppressed because it is too large Load diff

View file

@ -254,6 +254,28 @@ namespace TINK
.CreateLogger();
}
/// <param name="uri">The URI for the request.</param>
/// <summary>Overriden to respond when the user initiates an app link request.</summary>
protected override void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
// TODO: Adjust to correct host
if (uri.Host.ToLower() == "sharee.bike")
{
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query
.Substring(1)
.Split("&")
.Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
// segments == ["sharee", "lastenrad"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it
}
}
/// <summary> Gets the current logging level.</summary>
/// <returns></returns>
private static LogEventLevel GetCurrentLogEventLevel()

View file

@ -4,11 +4,28 @@ using Android.Content.PM;
using Android.OS;
using Android.Content;
using Java.Interop;
using Xamarin.Forms.Platform.Android.AppLinks;
using Firebase;
namespace TINK.Droid
{
[Activity (Label = "Mein konrad", Icon = "@drawable/sharee", Theme="@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "https",
DataHost = "sharee.bike", // TODO: Adjust to correct domain
DataPathPrefix = "/",
AutoVerify = true)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "http",
DataHost = "sharee.bike", // TODO: Adjust to correct domain
DataPathPrefix = "/",
AutoVerify = true)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate (Bundle bundle)
{
@ -19,6 +36,9 @@ namespace TINK.Droid
global::Xamarin.Forms.Forms.Init (this, bundle);
FirebaseApp.InitializeApp(this);
AndroidAppLinks.Init(this);
// Initialize xamarin.essentials, see https://docs.microsoft.com/en-us/xamarin/essentials/get-started?tabs=macos%2Candroid.
Xamarin.Essentials.Platform.Init(this, bundle);

View file

@ -190,6 +190,9 @@
<PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="117.6.0.2" />
<PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="117.0.1.1" />
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="117.2.1.1" />
<PackageReference Include="Xamarin.Forms.AppLinks">
<Version>5.0.0.2244</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Android" />

File diff suppressed because it is too large Load diff

View file

@ -254,6 +254,28 @@ namespace TINK
.CreateLogger();
}
/// <param name="uri">The URI for the request.</param>
/// <summary>Overriden to respond when the user initiates an app link request.</summary>
protected override void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
// TODO: Adjust to correct host
if (uri.Host.ToLower() == "sharee.bike")
{
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query
.Substring(1)
.Split("&")
.Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
// segments == ["sharee", "lastenrad"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it
}
}
/// <summary> Gets the current logging level.</summary>
/// <returns></returns>
private static LogEventLevel GetCurrentLogEventLevel()

View file

@ -4,11 +4,28 @@ using Android.Content.PM;
using Android.OS;
using Android.Content;
using Java.Interop;
using Xamarin.Forms.Platform.Android.AppLinks;
using Firebase;
namespace TINK.Droid
{
[Activity (Label = "Sharee", Icon = "@drawable/sharee", Theme="@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "https",
DataHost = "sharee.bike",
DataPathPrefix = "/",
AutoVerify = true)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.ActionView, Intent.CategoryBrowsable, Intent.CategoryDefault },
DataScheme = "http",
DataHost = "sharee.bike",
DataPathPrefix = "/",
AutoVerify = true)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate (Bundle bundle)
{
@ -19,6 +36,9 @@ namespace TINK.Droid
global::Xamarin.Forms.Forms.Init (this, bundle);
FirebaseApp.InitializeApp(this);
AndroidAppLinks.Init(this);
// Initialize xamarin.essentials, see https://docs.microsoft.com/en-us/xamarin/essentials/get-started?tabs=macos%2Candroid.
Xamarin.Essentials.Platform.Init(this, bundle);

File diff suppressed because it is too large Load diff

View file

@ -190,6 +190,9 @@
<PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="117.6.0.2" />
<PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="117.0.1.1" />
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="117.2.1.1" />
<PackageReference Include="Xamarin.Forms.AppLinks">
<Version>5.0.0.2244</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
@ -663,6 +666,9 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\sharee_no_background.png" />
</ItemGroup>
<ItemGroup>
<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
<Import Project="..\TINK\TINK.projitems" Label="Shared" Condition="Exists('..\TINK\TINK.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ProjectExtensions>

View file

@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "1088928386656",
"project_id": "shareetest-46bf8",
"storage_bucket": "shareetest-46bf8.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1088928386656:android:84c634fd6c64679a22fd05",
"android_client_info": {
"package_name": "com.TeilRad.sharee.bike"
}
},
"oauth_client": [
{
"client_id": "1088928386656-vot2dsqetl5cegf15aheu5v8kl8iud0b.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBDHV9nrt1Wy20f8GkFZroi3kH_YQ8rfgQ"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1088928386656-vot2dsqetl5cegf15aheu5v8kl8iud0b.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View file

@ -254,6 +254,27 @@ namespace TINK
.CreateLogger();
}
/// <param name="uri">The URI for the request.</param>
/// <summary>Overriden to respond when the user initiates an app link request.</summary>
protected override void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
if (uri.Host.ToLower() == "sharee.bike")
{
// Input e.g. sharee.bike/sharee/lastenrad/?lat=49.921&long=32.51
Array segments = Array.ConvertAll(uri.Segments, segment => segment.Replace("/", "")).Skip(1).ToArray();
Dictionary<string, string> queryDict = uri.Query
.Substring(1)
.Split("&")
.Select(query => query.Split('='))
.ToDictionary(query => query.FirstOrDefault(), query => query.Skip(1).FirstOrDefault());
// segments == ["sharee", "lastenrad"]
// queryDict == [{["lat", "49.921"]}], {["long", "32.51"]}]
// => Navigate and pass params depending on linkinput
// If no custom navigation is configured, the app just opens as if the user opened it
}
}
/// <summary> Gets the current logging level.</summary>
/// <returns></returns>
private static LogEventLevel GetCurrentLogEventLevel()