位智深层链接

Waze Deep Links

我正在使用 Xamarin Forms(跨平台)开发一个应用程序,我试图从我的应用程序打开 Waze 应用程序,传递纬度和经度。
它打开 Waze 很好,但是 Waze 只是打开,它没有尝试找到地址或我传递的 latitude/longitude。

string stringUri = @"waze://ul?ll=" + client.Latitude + ","  + client.Longitude + "&navigate=yes";
Intent intent = new Intent(Intent.ActionView);
intent.AddFlags(ActivityFlags.NewTask);
intent.SetData(Android.Net.Uri.Parse(stringUri));
Android.App.Application.Context.StartActivity(intent);

关于如何让它发挥作用的一些想法?

---编辑---
最后,它奏效了,使用来自@SushiHangover 的想法,我设法实现了预期的结果。最终代码在这里:

public static Task < bool > OpenWazeAndroid(decimal latitude, decimal longitude, string address) {
    var lat = latitude.ToString().Replace(",", ".");
    var longi = longitude.ToString().Replace(",", ".");
    const string wazePrefix = "waze://";
    Android.Content.Intent intent = new Android.Content.Intent(Android.Content.Intent.ActionView, Android.Net.Uri.Parse(wazePrefix));
    string wazeURL = ("https://waze.com/ul?q=" + address + "&ll=" + lat + "," + longi + "&z=8&navigate=yes");
    wazeURL = wazeURL.Replace(" ", "%20");
    var resolveInfo = Android.App.Application.Context.PackageManager.ResolveActivi‌​ ty(intent, 0);
    Android.Net.Uri wazeUri;
    if (resolveInfo != null) {
        wazeUri = Android.Net.Uri.Parse(wazeURL);
    } else {
        wazeUri = Android.Net.Uri.Parse("market://details?id=com.waze");
    }
    intent.AddFlags(Android.Content.ActivityFlags.NewTask);
    intent.SetData(wazeUri);
    Android.App.Application.Context.StartActivity(intent);

    return Task.FromResult(true);
}

Android 上的直接应用程序 link 不遵守 link properties/options(Waze iOS 遵守),因此请使用网络基础 url (https://waze.com) 使用深度 link 选项正确打开 Waze。

示例:

const string wazeAppURL = "waze://";
var wazeURL = $"https://waze.com/ul?ll={loc[0]},{loc[1]}&navigate=yes";
var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(wazeAppURL));
var resolveInfo = PackageManager.ResolveActivity(intent, 0);
var wazeUri = resolveInfo != null ? Android.Net.Uri.Parse(wazeURL) : Android.Net.Uri.Parse("market://details?id=com.waze");
intent.SetData(wazeUri);
StartActivity(intent);