Detect if a reactive app is running as a PWA or native .
Application Type
Mobile, Reactive

I am developing a reactive application that can be run as a PWA or a native application. I am implementing a barcode scanner which doesn't have a good solution for PWA. So I am hoping to implement 2 solutions ie; 

  • if the application is being launched as a native app - use the native plugin.
  • if the application is being launched as a PWAS - use the Javascript based scanner.

Is there a way for me to find if the instance of my application is running as a PWA or a native app ?

regards

Rakesh.V

Solution

Hello Rakesh,

You can use the action IsCordovaDefined from Common Plugin. This action will return true only if you are running in a native app. It is the better way to check if you are in an app or PWA/web. 

regards

Fabio

Doesn't this throw an exception if Cordova isn't defined ?

if you try to use the plugin directly, yes, you will throw an exception. But if you call the action, you will get a boolean without exception and you could do your own treatment for that.




Solution

Hi Rakesh,

You should be able to use the IsRunningAsPWA action from OutSystems UI and include it to the logic flows of your mobile application, and handle each case as necessary:

Let me know if that helps.

Hi,

This seems to be returning a false if I launch the application from my browser . What I was looking for was a solution to launch the native barcode scanner if I am running the app from an apk/ipa. Else launch the javascript version if running on a browser or PWA .

Thanks and Regards

Rakesh.V

Solution

Hello Rakesh,

You can use the action IsCordovaDefined from Common Plugin. This action will return true only if you are running in a native app. It is the better way to check if you are in an app or PWA/web. 

regards

Fabio

Doesn't this throw an exception if Cordova isn't defined ?

if you try to use the plugin directly, yes, you will throw an exception. But if you call the action, you will get a boolean without exception and you could do your own treatment for that.




Solution

Hi Rakesh,

You should be able to use the IsRunningAsPWA action from OutSystems UI and include it to the logic flows of your mobile application, and handle each case as necessary:

Let me know if that helps.

Hi,

This seems to be returning a false if I launch the application from my browser . What I was looking for was a solution to launch the native barcode scanner if I am running the app from an apk/ipa. Else launch the javascript version if running on a browser or PWA .

Thanks and Regards

Rakesh.V

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.