Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Open another app from my app



  • Goodevening!
    I would like to add a button that when clicked open another app i’ve made, if installed, or send the user to the store page to download it, how can i do this?



  • Hi @N_Developer ! Good evening!

    So, to you call a google play page, you’ll need:

    https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/

    <ons-icon icon="fa fa-share-square-o fa-2x" fixed-width="true" onclick="window.open(https://play.google.com/store/apps/details?id=codigo.flat.leo.moura123684748', '_system')"></ons-icon>
    

    To open an external app you’ll need :

    SocialSharing-PhoneGap-Plugin
    cordova-plugin-inappbrowser
    org.apache.cordova.startapp

    Check the app availability

     <script>
            function checkTwitter() {
                appAvailability.check(
                    'com.twitter.android', // Package Name
                    function () {           // Success callback
                        window.plugins.socialsharing.shareViaTwitter(' Download also ...', null /* img */, ' https://play.google.com/store/apps/details?id=codigo.flat.leo.moura123684746' /* url */, function () { console.log('share ok') }, function (errormsg) { alert(errormsg) })
                    },
                    function () {           // Error callback
                        ons.notification.confirm({
                            message: 'twitter is not installed . Do you want to download it?',
                            title: 'Application Unavailable',
                            buttonLabels: ['Yes', 'No'],
                            animation: 'slide',
                            primaryButtonIndex: 1,
                            cancelable: false,
                            callback: function (index) {
                                if (index == 0) {
                                    window.open('https://play.google.com/store/apps', '_system')
                                } else if (index == 1) {
     window.open('twitter://user?screen_name=gajotres', '_system', 'location=no');
                                }
    
                            }
                        });
                    }
                );
            }
    

    liked ? An upvote! ;)