UIPasteboard copying string to clipboard is not working on iOS 15 device

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.

Updated to iOS 15 beta 3, still same issue.

Can I ask how you managed to get this to work in the simulator in the first place? I'm simply trying to capture data and save it to a group container, but I can seemed to even print anything to the console from within the beginRequest:with: method. I'm assuming your code is within the SafariWebExtensionHandler class adhering to the NSExtensionRequestHandling protocol?

Yes this is in the SafariWebExtensionHandler class. You can print things to the console and view them when attaching the debug process to the Extension App

iOS 15 Beta 8 Xcode 13 beta 5 still same issue

UIPasteboard copying string to clipboard is not working on iOS 15 device
 
 
Q