Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS9 Safari content blocker extension not invoked

I'm playing with XCode7 beta, trying to test the shiny new "Content Blocker Extension". The example class is adopting the same NSExtensionRequestHandling protocol as the (already known) Sharing extension. The essential difference from Sharing extension is that the class is a plain NSObject, not a *ViewController subclass because, you know, a Blocker Extension isn't supposed to be showing any UI feedback. That's my understanding at least. Anyway the crucial method beginRequestWithExtensionContext which is supposed to feed the blocker declaration JSON to the extension point, does not get invoked. The extension does have TRUEPREDICATE as its NSExtensionActivationRule and Safari does acknowledge the existence of my host app in the new Safari config "Content Blockers". But still no cigar.

Does anybody know if it's even supposed to be already working this early in the beta or was it just a press release?

And, oh, while we're at it, is there any documentation of that declarative JSON format or it's just my Google-Fu failing me? :)

like image 868
Pavel Zdenek Avatar asked Jun 10 '15 12:06

Pavel Zdenek


4 Answers

How do you know the extension isn't getting invoked?

I built a very quick test app and did a simple NSLog() from the beginRequestWithExtensionContext method and it was getting called when the extension was switched on.

Also, fwiw, there's +[SFContentBlockerManager reloadContentBlockerWithIdentifier:completionHandler:] which lets you trigger an update from the main app, at will.

like image 63
Chris Jones Avatar answered Sep 22 '22 12:09

Chris Jones


There isn't any documentation yet, but I found that some characters in the url prevent the load of the JSON They are (the one I found, might be more): +(as prefix) , $, |, ^

like image 38
Itay Brenner Avatar answered Sep 20 '22 12:09

Itay Brenner


Is there any documentation of that declarative JSON format

The webkit.org blog post below seems to be the current best "official" documentation of the Content Blocker JSON format.

https://www.webkit.org/blog/3476/content-blockers-first-look/

like image 34
pkamb Avatar answered Sep 23 '22 12:09

pkamb


Use the device console to view a live log of the device. There you will see your NSLog() calls.

  1. Choose Window -> Devices from the Xcode menu.
  2. Choose the device in the left column.
  3. Click the up-triangle at the bottom left of the right hand panel to show the device console.
like image 32
Johannes Schröter Avatar answered Sep 20 '22 12:09

Johannes Schröter