corodva plugin with pwa when converting ionic app to pwa

118 views
Skip to first unread message

anuj namjoshi

unread,
Jul 10, 2017, 12:12:59 PM7/10/17
to phonegap
I am using ionic app now my plan to convert ionic to pwa.
But my issue is how to use cordova plugins those are not supporting to browser.
How to replace it ?
I am using sqlite2,file-opner and social sharing corodva  plugins in  my current project.
Let me now is there any solution

Kerri Shotts

unread,
Jul 10, 2017, 12:19:39 PM7/10/17
to phonegap
Short answer: you don't.

Longer answer: Cordova plugins aren't available anywhere else but inside a Cordova app. If you want the same app to work solely in a web browser, then you'll need to implement workarounds to the Cordova-specific features that you're using. For example, you could use Web SQL Storage when running in the browser, but do be aware that it has significant limitations, is deprecated and may disappear, and isn't supported on all browsers anyway. In that case, you'd need to provide different adapters so that you could use SQLite in Cordova but perhaps use IndexedDB or something else when running in a browser. For everything else, well, you'll need to find a web solution. For example, social sharing -- you'd need to integrate with the social networks you want to use and share with them directly (providing any needed UI). 

Regardless, you're going to need to know if you're running in a Cordova environment or in a browser environment, and then switch code paths as necessary in your app. The easiest way is to just have two different build processes, one that builds your PWA (and injects a value that indicates it is running in a browser), and the other that builds your Cordova app (and injects a corresponding value that you're using Cordova). There are lots of other ways too; a google search should turn them up.

Hope that helps!

Kerri Shotts

unread,
Jul 10, 2017, 12:21:05 PM7/10/17
to phonegap
Gah; botched my short answer!

Short answer: you don't use Cordova plugins in a browser context; replace them with something equivalent.
Reply all
Reply to author
Forward
0 new messages