0

so I am able to share data using App Groups but I was wondering if it is possible to update the data from Today's extension.

So in my iOS app I have a set of data that gets data from Firebase and updates the App group

Now my Today's extension can retrieve the App group data only if the iOS app has been opened.

I am trying to figure out a way to call the iOS app from Today's extension to update the data because the iOS has a method that calls Firebase which updates the App Group.

Is this even possible?

Rashwan L
  • 38,237
  • 7
  • 103
  • 107
PictureMeAndYou
  • 533
  • 2
  • 5
  • 16

1 Answers1

0

You can't communicate directly with your main app as you want. You can basically do two things:

  • Open your main app from your extension
  • Pass data through your shared container
Rashwan L
  • 38,237
  • 7
  • 103
  • 107
  • 2) By passing data through the shared container. That means the main has to update the shared container first to get the latest data on Today's Extension correct? – PictureMeAndYou Oct 22 '16 at 05:36
  • The main app will call the shared container and get the desired data, no need to update it. If you for example add a value to your `UserDefault` with your shared container app group from your extension, then the main app just have to call that `UserDefault` and get the data. Checkout my post [here](http://stackoverflow.com/a/33843163/5576310) that will give you a hint of this. – Rashwan L Oct 22 '16 at 05:41
  • What happens if the extension needs to get the latest data from the main app. Does the extension just call it? Btw I have the data working. But it's not updating unless I open the main app. – PictureMeAndYou Oct 22 '16 at 05:44
  • You can read/write from main app and extension and vice versa. – Rashwan L Oct 22 '16 at 05:45
  • 1
    I don't think you're understanding my question. So currently the main app updates the container but how do I tell the extension to update the container from the main app so the extension always gets the latest data. (I have it working like I said, but it's not always the latest data. It depends on when the main app was last opened.) – PictureMeAndYou Oct 22 '16 at 05:50
  • Well the extension will only get the data that´s currently in the container. Lets say that you open your extension, but haven´t opened the main app in a while then you´ll only get what´s currently in your container. Do you understand how I mean? If you get your data from some API, you can get it directly from your extension instead. – Rashwan L Oct 22 '16 at 05:56
  • Thanks that's exactly what I wanted to confirm. That it isn't possible to get the data, if you never opened the app. The issue is my extension can't use the same data (Firebase) because not supported for extensions – PictureMeAndYou Oct 22 '16 at 05:58
  • @PictureMeAndYou I am looking for same answer as you and it doesn't seem to be able to. I think Rashwan was suggesting to use an API. I am thinking to make a framework that would be loaded by both app or today extension, like loading core document, and being able to write / update it... be aware today extensions are monitored for ressources, and you will be killed if you can't update within 30s. – altagir Nov 13 '16 at 22:05