6

I'm using safari content blocker extension in my app, i want to use array for blocking using nsuserdefaults , but extension showing this error on reloadContentBlocker "Error Domain=SFErrorDomain Code=3 "(null)"", and here is my code for extension:

func beginRequest(with context: NSExtensionContext) 
{

    let userDefaults = UserDefaults.standard
    let decoded  = userDefaults.object(forKey: "teams") as! Data
    let decodedTeams = NSKeyedUnarchiver.unarchiveObject(with: decoded) as! NSArray
    let attachment = NSItemProvider.init(item: decodedTeams, typeIdentifier: kUTTypeJSON as String)

    let item = NSExtensionItem()
    item.attachments = [attachment]

    context.completeRequest(returningItems: [item], completionHandler: nil);

}

Please help me to remove this error.

brindy
  • 4,585
  • 2
  • 24
  • 27

1 Answers1

0

You might have an exception handling issue within the endpoint Swift code. Check the Console for further investigation. For example,

SafariWebExtensionHandler.swift:34: Fatal error: Unexpectedly found nil while unwrapping an Optional value
goodhyun
  • 4,814
  • 3
  • 33
  • 25