4

We're building a today widget on top of our iOS app which is working with Firebase. However we're struggling to access current signed-in user from the extension. The user at the main app is anonymous so passing credentials via shared container is not an option.

The only way that I found is passing uid and generate custom token to sign in but I was hoping to find out better way to share FIRUser between my main app and app extension. What would be the best way to achieve this?

Alp Keser
  • 165
  • 8
  • did you come up with a good solution for this? – siburb Sep 18 '17 at 06:20
  • Not really, we create another guest user for the widget. The issue here is there is no parameter to pass to authenticate same guest user. So it's a bit of duplication but it works. – Alp Keser Sep 19 '17 at 07:16

1 Answers1

0

You can share data between Host App and App Extension only using App Group. There is no way of direct communication between your Host App and App Extension.

Even though an app extension bundle is nested within its containing app’s bundle, the running app extension and containing app have no direct access to each other’s containers.

App Group is a shared container used by both Host App as well as App Extension. It is like UserDefaults that store key-value pairs.

So you can save your current user information in App Group from Host App and then access it in your Today Extension from the same App Group.

For more on App Groups refer to: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html

PGDev
  • 23,751
  • 6
  • 34
  • 88