Hi, I have a problem when using deeplink, I am making the call and capturing the return, however, when executing the MainActivity create again, it is generating an error... Below is the code that calls deepLink...
using Android.Content;
namespace AppFv.Droid.Services
{
public interface IIntentServices
{
public void SendPaymentIntent();
}
public class IntentServices : IIntentServices
{
public void SendPaymentIntent()
{
Android.Net.Uri.Builder uriBuilder = new Android.Net.Uri.Builder();
uriBuilder.Authority("pay");
uriBuilder.Scheme("payment-app");
uriBuilder.AppendQueryParameter("amount", "200");
uriBuilder.AppendQueryParameter("editable_amount", "0"); // 1 = true and 0 = false
uriBuilder.AppendQueryParameter("transaction_type", "CREDIT"); //DEBIT, CREDIT, VOUCHER
uriBuilder.AppendQueryParameter("installment_type", "MERCHANT"); //MERCHANT, ISSUER, NONE
uriBuilder.AppendQueryParameter("return_scheme", "return");
String order_id = "123";
if (order_id != null)
{
uriBuilder.AppendQueryParameter("order_id", order_id);
}
String installment_count = "1";
if (installment_count != null)
{
uriBuilder.AppendQueryParameter("installment_count", installment_count); // 2 to 99
}
Intent intent = new Intent(Intent.ActionView);
intent.AddFlags(ActivityFlags.NewTask);
intent.SetData(uriBuilder.Build());
Platform.CurrentActivity.StartActivity(intent);
}
}
}
And here is the code that receives the return, the MainActivity...
using Android.App;
using Android.Content.PM;
using Android.Content;
using Android.OS;
namespace AppFv
{
[Activity
(
Label = "AppFv",
Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation
)
]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[]
{
Intent.ActionView,
Intent.CategoryBrowsable,
Intent.CategoryDefault
},
DataScheme = "return",
DataHost = "pay-response",
AutoVerify = true)
]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (Intent.Action == Intent.ActionView)
{
OnNewIntent(Intent);
}
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
var data = intent?.Data;
var returnScheme = data?.GetQueryParameter("return_scheme");
}
}
}
Can someone help me?