I try to use the sumup-android-api. It works fine until the callback is triggered. It somehow starts a second instance of my app inside the sumup app, doesn't it?
First instance:
Second instance inside the sumup-App, have a look at the app-icon.
I start the sumup process like this:
Launcher.Default.OpenAsync(@"sumupmerchant://pay/1.0?affiliate-key=itsasecret&app-id=dummyapp&total=5.00¤cy=EUR&title=1000084564&skip-screen-success=true&callback=renditewebclient://sumup");
My MainActivity.cs
looks like this:
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using System.Diagnostics;
namespace RenditeBrowser
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.ActionView, Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "renditewebclient", DataHost = "sumup")]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
if (this.Intent != null)
{
Intent intent = this.Intent;
var action = intent.Action;
var strLink = intent.DataString;
if (Intent.ActionView == action && !string.IsNullOrWhiteSpace(strLink))
{
if (strLink.Contains("sumup"))
{
System.Diagnostics.Trace.WriteLine("Intent-Data: " + strLink);
}
}
}
base.OnCreate(savedInstanceState);
}
}
}
What am I doing wrong?
You can read the official document about the Tasks and the back stack. And about the launchMode:
"standard"
The default mode. The system creates a new instance of the activity in the task it was started from and routes the intent to it. The activity can be instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances.
So you can change the launchmode to SingleTask or SingleInstance:
Such as:
[Activity(Theme = "@style/Maui.SplashTheme", LaunchMode = LaunchMode.SingleTask, MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.ActionView, Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "renditewebclient", DataHost = "sumup")]
public class MainActivity : MauiAppCompatActivity