0

My javascript Ad works fine with google chrome app over iphone, but if i try load that Ad using UIWebView or even Safari on iphone it never executed.

i am using this line of code to load the Ad: [self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://sample_JavaScript_AD.html"]]];

i am testing this over iOS 10.

is there any updates from apple about safari & javascript ?

  • Where is this sample_JavaScript_AD.html file stored? What is serving it up to the "browser" (the UIWebView)? – Chris Edgington Mar 15 '17 at 15:40
  • If the file is stored in your application bundle, check this out for the answer: http://stackoverflow.com/questions/7063276/how-to-load-local-html-file-into-uiwebview – Chris Edgington Mar 15 '17 at 15:41
  • Your html page is https? If not did you add App Transport Security Settings to including your domain to your Info.plist file? If your html page is not https then add app transport settings. You can take a look at this [link](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) – abdullahselek Mar 15 '17 at 16:01
  • @ChrisEdgington it saved on my own server , and iam using both uiwebview and wkwebview and both did not work , and there is no file ! , it just url , and yes i am sure i added App Transport Security Settings. .... all of this did not work ! – Sidky Sobhy Mar 15 '17 at 16:29

1 Answers1

0

Your URL needs to include the full server address, not just the filename. For example:

self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mywebserver.com/sample_JavaScript_AD.html"]]];
Chris Edgington
  • 1,208
  • 12
  • 11