Interactions between iOS browser app developed in Swift and the embedded html code

Dear users,


I'm developing a iOS app with a internal browser for a embedded HTML page; I'm using swift. I have only two questions about the interactions between this two elements.

1) How can I communicate or share data between my iOS browser and the HTML page (precisely, the javascript code in this page)?

2) If the user open a new web page from another page from my browser, I want that the new page opens in the browser of my iOS app and not in native browser. How can I do this?


Thank in advance for you attention!

Are you using WKWebView or UIWebView? For stuff like this you probably want WKWebView because it has a lot more options. Specifically:

  • For your first question, WKWebView has a whole 'user script' mechanism. It's too complex to explain here but I believe it's covered in some detail in WWDC 2014 Session 206 Introducing the Modern WebKit API.

  • For your second question, I believe you can do this via the

    -webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:
    delegate callback.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Dear Eskimo,

thank for your reply. The first, and most complicated, question is solved. Related to second, could you please show me only a link or webpage in which the scroll effect I search is explained? I have try to search it but without result.


Thank!

could you please show me only a link or webpage in which the scroll effect I search is explained?

What scroll effect? This is the first time you've mentioned scrolling, so I'm struggling to find the context here.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Interactions between iOS browser app developed in Swift and the embedded html code
 
 
Q