MMWormhole
MMWormhole copied to clipboard
Message passing is silently failing when using keyboard extension on iOS 13.5
I've run into a weird problem with message passing between a custom keyboard app extension and its containing app.
Following this post, I'm setting up a wormhole in both with let wormhole = MMWormhole(applicationGroupIdentifier: "group.com.mytestgroup", optionalDirectory: nil)
, then I do:
- In the custom keyboard, I trigger sending a message off a keypress. The line I use to send the message is:
self.wormhole.passMessageObject("the message" as NSCoding, identifier: "id1")
- In the containing app, I create a listener with:
self.wormhole.listenForMessage(withIdentifier: "id1", listener: { (message) -> Void in
print("message received")
if let messageFromKeyboard = message as? String {
print(messageFromKeyboard)
}
})
I would expect that after creating the listener in the containing app, a key press in the custom keyboard would cause the listener to get the message and print both "message received" and the actual message to the console. I've confirmed that this happens as expected in the xcode simulator, but it doesn't happen on my iPad...it just fails silently. No error messages....just nothing happens.
Any idea what might be going on here? Is there any problem using MMWormhole for custom keyboards?
Relevant info:
- My iPad is iOS 13.5.1
- Using MMWormhole 2.0.0 installed as a cocoapod
- I saw the troubleshooting suggestion here but at least in my current version of xcode I see no "steps" checkmarks. Just a list of app groups.
- Regardless, I think my app group is set up appropriately, considering the wormhole setup line
let wormhole
fails if I change the group id. - I'm using
wormhole.listenForMessage
as opposed tolistenForMessageWithIdentifier
because I get an error with the latter. Xcode suggested to change it to the former. Similar with theas NSCoding
part above. I don't think these tidbits are substantial though, considering things work in sim.