How to integrate/use `WKWebView` plugin in PhoneGap application - ios

I have a Phonegap iOS application in which I am using Angular Kendo mobile framework for build UI.
I want to use WKWebView in my application instead of UIWebView.
So what all steps I need to follow to do so?
I tried to integrate it by adding the WKWebView plugin but in my application I see blank page only and in logs errors for loading html pages.

You have to install the plugin like this:
cordova plugin add cordova-plugin-wkwebview
And after that in your config.xml add this:
<plugin name="cordova-plugin-wkwebview" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

Related

Ionic WKWeabView breaks Template on iOS

I was trying to publish my application on Apple Store, but they blocked it since UIWebView was detected. I found no “UIWebView” occurrences in the project, but the application is still being blocked by the Store.
I found on the Internet that I had to install WKWebView using the following command:
$ ionic cordova plugin install cordova-plugin-ionic-webview --save
Then I had to fix the config.xml in the following way:
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
The application starts, but when I do a GET on a page and try to display the response I have the following result: https://imgur.com/a/uaBWZOf
The first card is static, while the others are dynamic: the static card is displayed correctly, while the dynamic ones are displayed only opening the side menu or clicking the filters. No chance to get the dynamic content on the opening of the page.
The code that generates dynamic content is correct since it runs correctly on Android side and on iOS side without WKWebView installed too.
Ionic version: 6.17.1
Cordova version: 7.1.0
Any idea of what could be what could cause the card problem and how to fix it?

Cordova iOS no longer loading three.js .glb files

I have a Cordova app (built with react) which renders 3d (.glb) models on my iPhone (using three.js).
It's old, and used Cordova's iOS#5 platform. I updated it to Cordova's newer ios#6 platform, and the .glb files no longer load on the iPhone.
They load fine locally, when run in the browser. but they do not load in the iPhone. If I use the older ios 5, it works fine.
Is there a known reason three.js no longer works in ios6? a plugin that needs to be added? a build setting that must now be added that didn't before?
It's most probably because you were running UIWebView which has been deprecated. Now WKVebView does not allow to load files like UIWebView used to.
You could give a try to this plugin https://github.com/globules-io/cordova-plugin-ios-xhr and then set your preferences to
<preference name="AllowUntrustedCerts" value="true" />
<preference name="InterceptRemoteRequests" value="all" />
<preference name="allowFileAccessFromFileURLs" value="true" />
<preference name="allowUniversalAccessFromFileURLs" value="true" />
Note that this is for iOS 6+

cordova (visual studio) ios plugin with custom framework not packaged?

tried things from this thread , did not work for me.
Basically I am writing a custom plugin for ios, using cordova tool (v5.4) for Visula Studio, and I need to reference a framework (with my dynamic libs). Following instructions, everything built ok, but the app aborts on launching.
By looking at the size of ipa file, looks like my libs/framework are not being packaged (if they were, the size would have been significantly larger).
Here is how my plugin.xml looks like
<config-file target="config.xml" parent="/*">
<feature name="myCDVPlugin">
<param name="ios-package" value="myCDVPlugin" />
</feature>
</config-file>
<header-file src="src/ios/myTest.h" />
<source-file src="src/ios/myTest.m" />
<framework src="src/ios/myLibs.framework" custom ="true"/>
<framework src="UIKit.framework" />
<framework src="Foundation.framework" />
BTW, here is the crash log dumped from the device--
Dyld Error Message:
Library not loaded: #rpath/myLibs.framework/myLibs
Referenced from: /private/var/mobile/Containers/Bundle/Application/77A1CF1C-0C2B-4EBC-A2AB-3CF362E0CD9D/com.test.app/test
Reason: image not found
Dyld Version: 353.12
I had a similar error when i tries to embed a custom swift framework to my project.
What worked for me is to go to the project build settings and change the 'Embedded Content Contains Swift Code' to 'YES'.
Hope it works for you.

Camera plugin is not working in phonegap app for ios

I am new to ios development.
I have created an app with phonegap its working fine with android.
But for IOS its not working. I have installed all the plugins.
Right now i am testing the camera plugin.
But its showing the following error.
Error: Can't find variable: Camera ionic.bundle.js:20306
clickPicture#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/app/common/camera-service.js:11:38
_takePicture#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/app/registration/registeration-controller.js:54:44
$parseFunctionCall#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:21044:23
file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:53439:21
$eval#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:23100:28
$apply#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:23199:28
file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:53438:19
eventHandler#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:11713:25
dispatchEvent#[native code]
triggerMouseEvent#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:2863:20
tapClick#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:2852:20
tapTouchEnd#file:///private/var/mobile/Containers/Bundle/Application/CF215D1D-130F-4901-B935-C086A94A5579/test_proj.app/www/lib/ionic/js/ionic.bundle.js:2975:13
there are two config.xml files in my project
one is in root folder and other one is in staging folder
i made entry of camera plugin in both files as well as tried with individuals file.
i have tried with two types of entries in config.xml
first one :
<feature name="Camera">
<param name="ios-package" value="org.apache.cordova.camera" />
</feature>
Second one
<feature name="Camera">
<param name="ios-package" value="CDVCamera" />
</feature>
But its continuously showing the same error.
here is my project file structure.
i am trying to fix it from last two days. But dont know where i am wrong.
After spent a lot of time. I found that the plugin was not updating ionic.bundle.js for that i just run the cordova platform update ios command.
And now its working fine.

Is there any possibility to disable the screen rotation of the app in jquery-mobile

Hey guys i'm using phonegap and jquery mobile to build an app for an android phone. Is there any possibility to disable the screen rotation of the app. I am very new to jquery mobile. Sorry if I am asking inappropriate question.
Yes it's possible but you must set it in cordova/phonegap parameter not in your app/www
in your app folder there is config.xml
<preference name="orientation" value="default" />
<!-- all: default means both landscape and portrait are enabled -->
Do you want to do it only using Jquery? Can you think of using Android's Manifest file to fix an orientation for the activity?
Change the following attributes in manifest file:
android:screenOrientation="portrait" or android:screenOrientation="landscape" in the AndroidManifest.xml:
<activity android:name=".MyActivity"a
android:label="#string/app_name"
android:screenOrientation="portrait">
Include the following code in your 'config.xml'
<preference name="Orientation" value="landscape" />
or
<preference name="Orientation" value="portrait" />

Resources