I am currently developing a safari web extension on iOS.
The following piece of code is executed in the native application when the extension sends a message to the native app using browser.runtime.sendNativeMessage.
   func beginRequest(with context: NSExtensionContext) {
    let item = context.inputItems[0] as! NSExtensionItem
    let message = item.userInfo?[SFExtensionMessageKey]
    os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
//    Message should follow format of:
//    {
//     type: "Message type",
//     payload: "Message Payload"
//    }
//    In the future we may want to parse the payload differently, but for now it is a string
    guard let response = message as? [String : AnyObject] else {
      return
    }
    guard let type = response["type"] as? String else {
      return
    }
    guard let payload = response["payload"] as? String else {
      return
    }
     
    let res = NSExtensionItem()
     
    if type == "COPY" {
      let itemToCopy = [payload]
      let pasteboard = UIPasteboard.general
      pasteboard.strings = itemToCopy
      res.userInfo = [ SFExtensionMessageKey: [ "res": true ] ]
    }
    context.completeRequest(returningItems: [res], completionHandler: nil)
The code works flawlessly in the iOS 15 simulator, however it does not work on the actual device. ( iPod Touch 7th Generation running iOS 15 beta 2 )
There are no errors, it behaves as if it was working as expected.
Any help would be greatly appreciated.