I'm working on a project in which, I have UIWebView
where I need to call some JavaScripts
on a webpage in this UIWebView
and that particular JavaScript
will call my Objective-C
native method.
To do that, I'm fetching context
from UIWebView
and setting my Objective-C
object to the context
and this object I'm fetching in JavaScript
and In JavaScript, object I'm calling a Objective-c
with this function/method.
Here is the code I'm using to do above,
JSContext *context = nil;
context = [_webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
// enable error logging
[context setExceptionHandler:^(JSContext *context, JSValue *value) {
NSLog(@"WEB JS: %@", value);
}];
context[@"MyObj"] = self;
So my simple question is, whether this way of doing this is ok, in terms of Apple Store. I mean, is there something that can cause my app to get rejected my Apple for App Store?
Thanks.
There is nothing currently in the App Store guidelines that would prohibit what you intend to do.
The ability to initiate functionality from a web server, even if it's via JavaScript in a web view, is common behavior.
Your app is run in a sandbox, so any security concerns are limited to your app. You're not adding code to your app, which is strictly prohibited. You're simply including functionality that may be called at a later time.