This is a migrated thread and some comments may be shown as answers.

Click button to launch another Telerik app on same device

2 Answers 86 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ben
Top achievements
Rank 1
Ben asked on 10 Nov 2014, 07:34 PM
Is it possible to click a button which launches another Telerik app on the same device, instead of closing the current app, then opening the other app from the phone manually? If so, can I pass the newly opening app a parameter such as the username of the user that is opening it?

2 Answers, 1 is accepted

Sort by
0
Ben
Top achievements
Rank 1
answered on 10 Nov 2014, 08:21 PM
I now have this code in the html file:

<a class="intent"  
            href="http://facebook.com/someProfile"  
            data-scheme="com.telerik.VCareEvents://view?id=loginTablet.html">Events</a>
                 
             
            <script>
                // `intent` is the class we're using to wire this up. Use whatever you like.
                $('a.intent').on('click', function (event) {
                    uriSchemeWithHyperlinkFallback($(this).data('scheme'), $(this).attr('href'));
                    // we don't want the default browser behavior kicking in and screwing everything up.
                    event.preventDefault();
                });
            </script>

And this in my js:

// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
    // set up a timer and start it
    var start = new Date().getTime(),
        end,
        elapsed;
  
    // attempt to redirect to the uri:scheme
    // the lovely thing about javascript is that it's single threadded.
    // if this WORKS, it'll stutter for a split second, causing the timer to be off
    document.location = uri;
  
    // end timer
    end = new Date().getTime();
  
    elapsed = (end - start);
  
    // if there's no elapsed time, then the scheme didn't fire, and we head to the url.
    /*if (elapsed < 1) {
        document.location = href;
    }*/
}

When i uncomment the bottom js code it goes to the facebook page. I just need to find out the corrent data-scheme of the VCare Events app (another Telerik app) any idea how I do that?
0
Zdravko
Telerik team
answered on 13 Nov 2014, 12:21 PM
Hello Ben,

Straight to your question. Yes, you can open one app from another by using URL scheme and we have a sample app demonstrating it. The app uses WebIntent plugin for Android part so consider reviewing its help documentation.

You can also add some parameters which you will have to handle on the launched app side. Following this link you will find another similar plugin which provides additional guidance about parameters handling.
I hope any of them will help you achieve your goals.

Regards,
Zdravko
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
Apache Cordova
Asked by
Ben
Top achievements
Rank 1
Answers by
Ben
Top achievements
Rank 1
Zdravko
Telerik team
Share this question
or