Let me explain my question it is bugging me from long time. Any help will be appreciated. Please help.
I am working on hybrid kind of app in iOS. I am using UIWebView
for loading webpages from http://myserver.com (its example its not actual URL) I have hosted multiple webpages on this server.
I am using "JSContext" to communicate between javascript (webpages loaded from my server) in UIWebView
and native iOS functions.
I have followed procedure given at UIWebView JavaScript losing reference to iOS JSContext namespace (object) the context was getting lost but I have added workaround provided in solution of this question.
Event then for some frame load inside UIWebView
my iOS context is getting vanished.
After following following steps context gets vanished.
UIWebView
. Almost all works well all functions OS native iOS are called from javascript.UIWebView
javascript context gets vanished.There is one more magical thing. if I have directly load page2 in UIWebView
instead of indirect loading (page1->page2). All works well all native methods are called from UIwebView
as expected.
Please help. If you want more info please ask.
First of all, stealing and using the UIWebView's JavaScriptContext in this way is likely a path to app rejection.
But if this is just a science project...
You might try another technique for obtaining the JavaScriptContext. I present a solution in this GitHub project:
https://github.com/TomSwift/UIWebView-TS_JavaScriptContext
Basically I'm using some knowledge of how WebKit works to implement a category on NSObject to intercept some non-handeled WebKit delegate methods which are called whenever a new JavaScriptContext is created for a frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With