MAUI中如何打开应用商店应用详情页

//打开应用商店详情页
public async Task<bool> OpenStoreAppDetails(string appId)
{
    string uri = string.Empty;
#if WINDOWS
    uri = $"ms-windows-store://pdp/?ProductId={appId}";
#elif ANDROID
    uri = $"market://details?id={appId}";
#elif IOS || MACCATALYST
    uri = $"itms-apps://itunes.apple.com/app/id{appId}";
#elif TIZEN
    uri = $"tizenstore://ProductDetail/{appId}";
#endif
    return await Launcher.Default.OpenAsync(uri);
}

appId 在 Windows 中为 App 的 ProductId

appId 在 iOS/MacCatalyst 中为 App 的 bundle ID

appId 在 Android 中为 App 的包名

如果Android想变成出现弹窗自己选择应用商店,而不是打开默认应用商店

#if ANDROID
public Task<bool> OpenStoreAppDetails(string appId)
{
    var uri = new Uri($"market://details?id={appId}");
    var intent = new Intent(Intent.ActionView, AndroidUri.Parse(uri.OriginalString));
    var chooserIntent = Intent.CreateChooser(intent, string.Empty);
    var flags = ActivityFlags.ClearTop | ActivityFlags.NewTask;
    chooserIntent!.SetFlags(flags);
    Application.Context.StartActivity(chooserIntent);
    return Task.FromResult(true);
}
#endif
posted @ 2023-02-08 12:58  Yu-Core  阅读(93)  评论(0编辑  收藏  举报