【问题标题】:how to open playstore app url on button click in angular2 nativescript如何在angular2 nativescript中单击按钮时打开Playstore应用程序网址
【发布时间】:2017-08-07 14:50:05
【问题描述】:

单击按钮时,我需要在 Playstore 应用程序的帮助下打开 Playstore 应用程序 url。我有很多来自 Playstore 的应用网址。

例如: https://play.google.com/store/apps/details?id=com.ninjakiwi.bftg

应用程序不应在浏览器的帮助下打开。单击按钮时,它必须在官方 google playstore 应用程序的帮助下打开。

【问题讨论】:

    标签: angular typescript nativescript angular2-nativescript


    【解决方案1】:

    您可以使用谷歌提供的应用商店链接。 例如:

    ma​​rket://details?id=

    这种方式选择选项不会出现并直接在playstore中打开。 这里 id = 你的 playstore appID 例如:com.ninjakiwi.bftg (在你的情况下)

    ma​​rket:// 启动 Play 商店应用以加载目标页面。

    http:// 让用户选择是否启动 Play 商店应用 或浏览器来处理请求。如果浏览器处理 请求,它会加载 Google Play 网站上的目标页面。

    参考:https://developer.android.com/distribute/marketing-tools/linking-to-google-play.html

    好的。 window.location.href 在这里不起作用。所以这里是你的完整解决方案:

    您必须使用 Nativescript 提供的 utils/utils 模块

    import { Component, OnInit } from "@angular/core";
    
    import * as utils from "utils/utils";
    
    @Component({
        selector: "ns-details",
        templateUrl: "./item-detail.component.html",
    })
    export class ItemDetailComponent implements OnInit {
    
        constructor(
        ) { }
    
        ngOnInit(): void {
        }
    
        openURL() {
            utils.openUrl("market://details?id=com.ninjakiwi.bftg");
        }
    }
    

    此处的 openURL 函数将在视图中的按钮点击事件上调用。 更多的: https://docs.nativescript.org/core-concepts/utils

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-28
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多