I have a requirement to open the native version of the hybrid app (.ipa/.apk/.appx) when the hybrid app is requested in a device browser.
I am able to detect the environment using WL.Client.getEnvironment();
method, if it is found to be Android/iPad, I want to launch the respective .apk/.ipa file in the device. Any help is appreciated.
Are you asking that if the user via their device browser hits the webapp version of your app on the internet, the website will ask the user to fire up the native app on their device? kind of like what ebay does? if that is what you want check out these pages
android:Launch custom android application from android browser
IOS: iPhone - Open Application from Web Page
Re-reading this question and the comments several times... I still do not understand the actual scenario... it'd be best to rephrase it.
Scenario: How to open an app from the web browser:
If you have added the following environments to your Worklight application:
And when visiting the Mobile Web version of your app, you want to display a message like "For the full experience, open the full application by clicking here".
Then:
The way to handle this scenario is to use URI schemas:
For Android: How to implement my very own URI scheme on Android
This means that after adding the custom URI schema to
AndroidManifest.xml
, you could then detect the device OS the Mobile Web app is currently running on and display a custom link:myapp://<the URI schema you've defined>
. Tapping it will open the app installed on the device.For iOS, in a similar fashion: https://coderwall.com/p/mtjaeq
Alternate solution: If you are not sure if the app will be installed or not, then instead of using URI schemas you can always point to either Google Play or Apple App Store, to the app page; the user will then have either a "Open" or "Install" link.
Scenario: How to open an app from my own app
If you have a Worklight Hybrid application (Mobile Web is not a Hybrid application), and you want to open another application from within it, you can:
I have created this Worklight 6.1.0 project to demonstrate:
apps\test
folder.