2

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.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • I understand what you're asking, but the scenario is very strange to me. You have a Worklight Hybrid app as well as some native app installed on your device, and you want to open the native app when a Hybrid app is "Requested in the device web browser"? I don't understand this. Please rephrase the question. – Idan Adar Dec 16 '13 at 13:47
  • Do you mean that you are in the Hybrid app and you want to launch another app by clicking a button or link while in the app? – Idan Adar Dec 16 '13 at 13:47
  • @IdanAdar: Yes, this hybrid application is targetted for iPad, Android & Windows tablets and Desktop version. We want to restrict the users accessing the app in device browsers' and force the user to launch the same app installed on the device – user3107490 Dec 16 '13 at 13:53
  • If it is a Hybrid app, why and how would they open it from a browser? It sounds like you are talking about a mobile web app. Please be MUCH clearer in what you're talking about. – Idan Adar Dec 16 '13 at 18:30
  • How is a Hybrid app reauested in a device browser? Explain the scenario. – Idan Adar Dec 17 '13 at 05:17
  • @Idan. It is a mobile web app. – user3107490 Dec 17 '13 at 06:18
  • A Worklight-based Mobile Web app is NOT a Worklight-based Hybrid app. Hybrid apps run on the device itself and Mobile Web apps are loaded in the device browser. A the end result of either a fully Native or Hybrid app is still an ipa/apk/appx file... You really need to REWRITE your question and better explain yourself. – Idan Adar Dec 17 '13 at 09:54

2 Answers2

3

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:

  • Mobile Web
  • Android
  • iPhone

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:

  1. It is implied that the user already has the application installed.
  2. If it is not installed, you need to take care of that somehow

The way to handle this scenario is to use URI schemas:

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:

  1. Use the same approach of URI schemas, or
  2. Use Cordova plug-ins

I have created this Worklight 6.1.0 project to demonstrate:

  • Android - How to open, for example, the Android Settings app from your Worklight Hybrid app
  • iOS - How to check if Waze is installed and open it, and if it is not installed then to open Apple Maps instead.
  • See instructions.txt in the apps\test folder.
Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Using URL Schemes is the right way to do it but is there no built in way in worklight to use open url scheme or writing a plugin is the only way to do so?? I tried Wl.openURL('fb:'); but it did not work. – Satheesh Dec 23 '13 at 06:12
  • There is not. While writing this answer I figured this could be a nice feature request. Feel free to submit this as a feature request, here: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014907906&ps=25 – Idan Adar Dec 23 '13 at 06:16
  • Did the same http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=43125, please let me know if it is fine. – Satheesh Dec 23 '13 at 07:20
  • It's okay. This is not a guarantee it will be implemented, now or at all. Thanks for the submission. – Idan Adar Dec 23 '13 at 07:28
1

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

Community
  • 1
  • 1
tik27
  • 2,698
  • 1
  • 16
  • 25