UIWebView-TS_JavaScriptContext icon indicating copy to clipboard operation
UIWebView-TS_JavaScriptContext copied to clipboard

-parentFrame is a private API

Open ItalyPaleAle opened this issue 10 years ago • 5 comments

My app got rejected by the static analyzer for using this method because -parentFrame is a private API.

I managed to solve that by checking on the delegate if the jsContext that's passed is the same as the context for the main frame:

- (void)didCreateJavaScriptContext:(JSContext *)jsContext
{
    // Get the context for the main frame and verify it's the same
    JSContext *mainFrameCtx = [self valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
    if(jsContext == mainFrameCtx) {
        // Call the delegate
        if(self.delegate && [self.delegate respondsToSelector: @selector(webView:didCreateJavaScriptContext:)] ) {
            [(id<TSWebViewDelegate>)self.delegate webView:self didCreateJavaScriptContext:jsContext];
        }
    }
    else {
        NSLog(@"JavaScript contexts are different");
    }
}

By using the delegate method, we're still sure that the JSContext object is created when we ask for it.

ItalyPaleAle avatar Jan 16 '15 14:01 ItalyPaleAle

@EgoAleSum

-[NSObject webView:didCreateJavaScriptContext: ]

I think this method is private Api too.I cant find the method in any ios document. :(

Lorem3 avatar Sep 07 '15 03:09 Lorem3

I think this method is private Api too.I cant find the method in any ios document. :(

It's not a 'private' API per-say, it's just not exposed. It is apart of the WebFrameLoadDelegate protocol, which originates on OSX. This makes sense if you consider the fact that UIWebView is an iOS wrapper around the OSX Class WebView. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Protocols/WebFrameLoadDelegate_Protocol/

matt-curtis avatar Sep 26 '15 22:09 matt-curtis

Your app uses or references the following non-public APIs:

parentFrame

The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

liyuunxiangGit avatar Aug 30 '16 07:08 liyuunxiangGit

I hope that we do not use this library, the bloody lessons.

2016年9月1日 上午1:22 发件人 Apple Performance - 2.5.1

Your app uses or references the following non-public APIs:

"parentFrame"

The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

feilongOnMoudu avatar Sep 01 '16 15:09 feilongOnMoudu

坑死我了 被拒两次

feilongOnMoudu avatar Sep 01 '16 15:09 feilongOnMoudu