Post

Replies

Boosts

Views

Activity

SwiftUI View not taking the whole space in UIHostingController
i am building an app that should run on iOS 13 and the my swiftui view is not shown correctly. There is a gap on the top and the bottom of the view. I guess the problem is within the SceneDelegate class because there I embed the view into an UIHostingController. func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). // Create the SwiftUI view that provides the window contents. let contentView = ContentView() // Use a UIHostingController as window root view controller. if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) window.rootViewController = UIHostingController(rootView: contentView) self.window = window window.makeKeyAndVisible() } } I also added everything needed in the info.plist. ![]("https://developer.apple.com/forums/content/attachment/2be7b17f-c9ef-4e21-ad1d-12a0d3dc72db" "title=Simulator Screen Shot - iPhone 11 - 2023-01-27 at 11.57.50.png;width=828;height=1792")
0
0
500
Jan ’23
Facing issues with ContentBlockerRequestHandler
Hello guys, I am currently working on a safari app extension that blocks content. I want the user to configure the rule (turning a rule on and off). Since I can’t overwrite the bundled JSON files and we can’t write to the documents folder, as it’s not accessible to the extension I decided to use App Groups. My approach looks like this: Within the ContentBlockerRequestHandler I want to save the blockerList.json into the app group (Only when launched for the first time) When this is done I want that the handler reads from the app group by taking the url of my json which is within the app group instead of taking the default json in the extension Since I can not debug the handler I don't know if I am on the right path. The following shows my code: / / class ContentBlockerRequestHandler: NSObject, NSExtensionRequestHandling {     func beginRequest(with context: NSExtensionContext) {                  guard let rulesUrl = loadRules() else {             let clonedRules = cloneBlockerList()             save(rules: clonedRules)             return         }                  guard let attachment = NSItemProvider(contentsOf: rulesUrl) else { return } //        let attachment = NSItemProvider(contentsOf: Bundle.main.url(forResource: "blockerList", withExtension: "json"))!                  let item = NSExtensionItem()         item.attachments = [attachment]                  context.completeRequest(returningItems: [item], completionHandler: nil)     }          private func cloneBlockerList() -> [Rule] {                  var rules: [Rule] = []         if let url = Bundle.main.url(forResource: "blockerList", withExtension: "json") {             do {                 let data = try Data(contentsOf: url)                 let decoder = JSONDecoder()                 let jsonData = try decoder.decode(ResponseData.self, from: data)                 rules = jsonData.rules             } catch {                 print("error:(error)")             }         }                  return rules     }          private func save(rules: [Rule]) {                  let documentsDirectory = FileManager().containerURL(forSecurityApplicationGroupIdentifier: "my group identifier")         let archiveURL = documentsDirectory?.appendingPathComponent("rules.json")         let encoder = JSONEncoder()         if let dataToSave = try? encoder.encode(rules) {         do {             try dataToSave.write(to: archiveURL!)             } catch {             // TODO: ("Error: Can't save Counters")             return;             }         }     }          private func loadRules() -> URL? {                  let documentFolder = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "my group identifier")         guard let jsonURL = documentFolder?.appendingPathComponent("rules.json") else {             return nil         }                  return jsonURL     } } Thankful for any help
1
0
812
Nov ’21
How to add div class as selector to blockerList.json ?
I am currently working on a safari app extension which blocks certain elements from a social media page. For example I want to block the number of likes. When checking in the web console of safari I see the div element  My problem now is I am not sure how I can block this element through my blockerList.json. This is my approach but it seem not to work: "action": { "type": "block", "selector": "div._97aPbwKWK0" } "trigger": { "url-filter": ".*instagram.*" } My question would be, do I have to inject some js or what would be a better approach ? Thankful for any help.
0
0
511
Nov ’21
Implementing a network filter for iOS
Hey guys, I am currently working on a network content filter app for iOS and have a few questions when it comes to using features from the network extension. I am a bit confused because this blog post https://www.x2mobile.net/blog/implementing-a-network-filter-on-an-ios-device mentions that when using the network extension you must supervise the apple device and create configuration profiles for the device. But when checking the example project provided by apple Apple Developer Documentation I see that they don’t mention these things. Why is this functionality only available for supervised iOS devices? Would every user who installs this app later on would need a configuration profile or am I completely wrong? Would be nice if you can tell me if that is necessary in my case. The same question can be formed differently. What do I have to adjust when using the example project from apple as a template for my iOS app? When it comes to storing rules I thought of adding them into a json file just for the beginning. Afterwards I thought of storing them into a database using Core Data since I want the user to also add custom rules to the filter. Since you also talk about the FilterControlProvider, I see in the documentation that the class FilterControlProvider is responsible for writing and reason information to disk. Would this class be responsible for fetching the rules from my database ? Thankful for any help
1
0
802
Oct ’21