PhoneGap recently released the new MultiView Plugin which supports iOS and Android. The MultiView plugin was required by many organizations to solve the challenge of launching multiple Cordova Webviews within one PhoneGap application. With the phonegap plugin expertise, each webview is fully independent, and communicates with local storage.
The Demo Application
PhoneGap has included a demo project in their code repository which can help to understand how the plugin works. The demo covers mainly two views: a “parent-view” and a “child-view” with the purpose of illustrating the parsing data between views. Please note that the plugin itself can support multiple views. The source code to the Demo Project is included in the PhoneGap repo, and to execute it in iOS/Android, you need to run below commands:
$ cd demo
$ cordova platform add ios (or) cordova platform add Android
$ cordova plugin add –link .. (Android does not link)
$ cordova run ios (or) cordova run Android
How to install Multiview plugin?
First step is to build your PhoneGap project and use the below command line to install the plugin
$ phonegap plugin add phonegap-plugin-multiview (or) cordova plugin add phonegap-plugin-multiview
$ PGMultiView.loadView(url, strPayload, success, error);
As this is the first version of the API, there are many improvements and functionalities required to add into the plugin. Feel free to check the complete documentation of the plugin available for download here in the PhoneGap Repo. You will face some issues of data storage and crash of the application from PGMultiView.java or PGMultiViewActivity in onStop() in the activity lifecycle. This is a primary bug which the PhoneGap team is working to resolve it. Did you face any other difficulty while using Multiview plugin? Let us know your thoughts in the comments below.