Deeplink не работает в мобильном Chrome в формах xamarinAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Deeplink не работает в мобильном Chrome в формах xamarin

Сообщение Anonymous »

Я работаю над формами xamarin, где мне приходится использовать Deeplink для Android. Deeplink работает из любого приложения для обмена сообщениями (Skype, WhatsApp и т. д.), но не работает ни в одном мобильном браузере.
ниже приведен мой код.
Я опубликовал код javasript deeplink.html

Код: Выделить всё

    


Veepee App




const urlParams = new URLSearchParams(window.location.search);
//document.getElementById('checkApp').addEventListener('click', function() {
window.addEventListener('load', function() {
var pageName = urlParams.get('page'); // Replace with the actual page name you want to pass

// Function to detect if the device is Android
function isAndroid() {
return /Android/i.test(navigator.userAgent);
}

// Function to detect if the device is iOS
function isIOS() {
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
}

if (isAndroid()) {
// Android-specific code
var appPackageName = 'com.companyname.veepee';
var appLink = 'intent://wholesale.veepeeonline.com/'+ pageName +'/#Intent;scheme=http;package=' + appPackageName + ';end';

// Attempt to open the app
window.location = appLink;

// Fallback to Play Store if the app is not installed
setTimeout(function() {
alert('App is not installed.');
window.location.href = 'https://play.google.com/store/apps/details?id=' + appPackageName;
}, 2000);
} else if (isIOS()) {
// iOS-specific code
var appLink = 'veepeedomain://veepeedomain/'+ pageName ;

// Attempt to open the app
window.location = appLink;

// Fallback to App Store if the app is not installed
setTimeout(function() {
alert('App is not installed.');
window.location.href = 'https://apps.apple.com/in/app/veepee-international/id6450380169';
}, 2000);
} else {
alert('Unsupported device.');
}
});



assetlinks.json

Код: Выделить всё

[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.companyname.veepee",
"sha256_cert_fingerprints": [
"debug sha....",
"release sha..."
]
}
}
]
AndroidMenifest.xml MainActivity.cs

Код: Выделить всё

 [Activity(Label = "Veepee", Icon = "@drawable/logo", Exported = true, Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTop)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "http",
DataHost = "wholesale.veepeeonline.com",
DataPathPrefix = "/",
AutoVerify = true,
Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]

[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "https",
DataHost = "wholesale.veepeeonline.com",
DataPathPrefix = "/",
AutoVerify = true,
Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
App.xaml.cs
защищенное переопределение void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);

Код: Выделить всё

      if (uri.Host.ToLower() == "wholesale.veepeeonline.com" && uri.Segments != null &&  uri.Segments.Length == 2)
{
var queryParams = System.Web.HttpUtility.ParseQueryString(uri.Query);
string name = queryParams["page"];
//string action = uri.Segments[1].Replace("/", "");
string action = name;
bool isActionParamsValid = long.TryParse(uri.Segments[1], out long productId);
Constants.PageNameFromURL = action;
Constants.OpenFromURL = true;
//if (action.ToLower() == "pendingreportview")
//{
//}
}
}
Пожалуйста, дайте мне решение
Заранее спасибо

Подробнее здесь: https://stackoverflow.com/questions/791 ... arin-forms
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»