Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Play Store URL on button click in Angular2 nativescript

I need to open Play Store url with the help of Play Store app when clicking on button. I have many app urls from Play Store.

For Eg: https://play.google.com/store/apps/details?id=com.ninjakiwi.bftg

App's page should not open in the browser. It has to open in official Google Play Store app when clicking on button.

like image 583
Steve Avatar asked Oct 20 '25 14:10

Steve


1 Answers

You can use app store link provided by Google. Ex:

market://details?id=

This way choose option will not come and directly open in playstore. Here id = your playstore appID ex: com.ninjakiwi.bftg (In your case)

market:// Launches the Play Store app to load the target page.

http:// Lets the user choose whether to launch the Play Store app or the browser to handle the request. If the browser handles the request, it loads the target page on the Google Play website.

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

Okay. window.location.href will not work here. So here is the complete solution for you:

You will have to use utils/utils module provided by Nativescript

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");
    }
}

Here openURL function will be called on button Tap event from view. More: https://docs.nativescript.org/core-concepts/utils

like image 113
Manish Kumar Avatar answered Oct 23 '25 03:10

Manish Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!