Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27987] iOS 14: Expose new APIs given in WKWebView

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2020-09-08T15:54:36.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.2.0
ComponentsiOS
Labelswebview
ReporterVijay Singh
AssigneeVijay Singh
Created2020-06-25T19:11:14.000+0000
Updated2020-09-08T15:54:36.000+0000

Description

In WKWebView Apple has given new APIs. e.g. 1. [pageZoom](https://developer.apple.com/documentation/webkit/wkwebview/3516411-pagezoom?changes=latest_minor&language=objc) 2. [createPDF](https://developer.apple.com/documentation/webkit/wkwebview/3516407-createpdfwithconfiguration?changes=latest_minor&language=objc) 3. [createWebArchivedData](https://developer.apple.com/documentation/webkit/wkwebview/3516408-createwebarchivedatawithcompleti?changes=latest_minor&language=objc) 4. [findString](https://developer.apple.com/documentation/webkit/wkwebview/3516409-findstring?changes=latest_minor&language=objc) Expose these APIs in titanium. Corresponding Titanium APIs - 1. Property
Ti.UI.WebView.zoomLevel
It already exists. Internal implementation, native side, will be changed. 2. Function
Ti.UI.WebView.createPDF(callback);
3. Function
Ti.UI.WebView.createWebArchive(callback);
4. Function
Ti.UI.WebView.findString(string, Options, callback);

Comments

  1. Vijay Singh 2020-07-22

    PR - https://github.com/appcelerator/titanium_mobile/pull/11834 Test Case - Steps - 1. findString - Click on button 'Search String (Measure)'. It should show alert, whether 'Measure' string is present or not. 2. createPDF - Click on button 'Create PDF of webpage'. It will create pdf data of webpage and the pdf data is opened in another webview. You should see pdf like page. 3. createWebArchive - Click on button 'Create Web Archive of page'. It will create webarchive data of webpage and the webarchive data will be opened in another webview. 4. zoomLevel - Click on button 'Zoom by factor 2'. It will zoom the webpage 2 times. This property is already exits in previous SDK for all iOS versions. In iOS 14 apple has introduced a dedicated API for same. So underlying implementation has changed in SDK. But behavior should be same.
       var win = Ti.UI.createWindow({
       	backgroundColor: '#fff'
       });
       
       var nextWin = Ti.UI.createWindow({
       	backgroundColor: '#fff'
       });
       
       var closeButton = Ti.UI.createButton({
       	top: 50,
       	title: 'Close'
       });
       
       closeButton.addEventListener('click', function() {
       	nextWin.close();
       });
       
       nextWin.add(closeButton);
       
       var nextWebView = Ti.UI.createWebView({
       	top: 100,
       });
       
       nextWin.add(nextWebView);
       
       
       var btn1 = Ti.UI.createButton({
       	top: 50,
       	left: 20,
       	title: 'Search String (Measure)'
       });
       
       btn1.addEventListener('click',  function() {
       	webView.findString('Measure', function(e){ // {'caseSensitive': true, 'backward': false, 'wraps': true},
       		if (e.success) {
       			alert('Searched string found!');
       		} else {
       			alert('Searched string not found!');
       		}
       	});
       });
       
       win.add(btn1);
       
       var btn2 = Ti.UI.createButton({
       	top: 50,
       	right: 20,
           title: 'Create PDF of webpage'
       });
       
       btn2.addEventListener('click', function() {
       	webView.createPDF( function(e) {
       		nextWebView.data = e.data;
       		nextWin.open();
       	});
       });
       
       win.add(btn2);
       
       var btn3 = Ti.UI.createButton({
       	top: 100,
       	left: 20,
           title: 'Create Web Archive of page'
       });
       
       btn3.addEventListener('click', function() {
           webView.createWebArchive(function(e){
       		nextWebView.data = e.data;
       		nextWin.open();
           });
       });
       
       win.add(btn3);
       
       var btn4 = Ti.UI.createButton({
       	top: 100,
       	right: 20,
           title: 'Zoom by factor 2'
       });
       
       btn4.addEventListener('click', function() {
           Ti.API.info('zoom level is ', +webView.zoomLevel);
           webView.zoomLevel = 2;
           Ti.API.info('zoom level is ', +webView.zoomLevel);
       });
       
       win.add(btn4);
       
       var webView = Ti.UI.createWebView({
       	url: 'https://appcelerator.com/',
       	top: 150,
       });
       
       win.add(webView);
       win.open();
       
  2. Samir Mohammed 2020-09-01

    FR Passed, waiting on Jenkins build and waiting for 9_3_X port.
  3. Samir Mohammed 2020-09-08

    *Closing ticket*. Fix verified in SDK version 9.2.0.v20200908050955, and 9.3.0.v20200908051946. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11834

JSON Source