With Split View, how can I talk to the parent app from its extension?

Here's the scenario: someone has my app open on their iPad Air 2. They open another app in Split View, say Safari. Then they activate my app's extension to share some content with my app. They wait for that content to appear in my app.


Normally I would use App Groups, save the data to a shared location, and check for it when the parent app activates. But in this scenario the app doesn't activate when the user returns to it—it was active the whole time. So unless I constantly check for new data it won't appear immediately in the parent app.


What's the best way to solve this? Is there a notification I can subscribe to? Maybe something that would fire when an NSUserDefault changes? Or do I need to use something like MMWormhole? https://github.com/mutualmobile/MMWormhole

Accepted Reply

It would be nice if NSUserDefaults took care of this for you; it even has a handy-dandy notification (

NSUserDefaultsDidChangeNotification
) that it could post in this case. Alas, that support wasn't wired up for the shared container case, at least when I last tried it on iOS 8.x.

You should re-test on iOS 9 beta to see if things have improved. If not, something like MMWormhole is your best way forward. And if you are forced down that path, please file a bug requesting better system-level support, and then post the bug number here just for the record.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

It would be nice if NSUserDefaults took care of this for you; it even has a handy-dandy notification (

NSUserDefaultsDidChangeNotification
) that it could post in this case. Alas, that support wasn't wired up for the shared container case, at least when I last tried it on iOS 8.x.

You should re-test on iOS 9 beta to see if things have improved. If not, something like MMWormhole is your best way forward. And if you are forced down that path, please file a bug requesting better system-level support, and then post the bug number here just for the record.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you. As of iOS 9 beta 4, NSUserDefaultsDidChangeNotification still does not work for this unfortunately. Filed rdar://22046331


I decided to give MMWormhole a shot—surprisingly simple to set up, and it works perfectly.