0

I am reading this sample app, and noticed that the call for subscriptions happens in viewDidLoad(). This raises the following question:

1) Is the user subscribed to event comments only when he/she is in that particular view controller? In other words, if the user navigates to another scene, is the subscription no longer in effect? How can I make it so that once a user subscribes to something, he/she is subscribed to it until told to stop?

I also have another question:

2) Can I changed the parameters passed to a subscription during the app? For instance, if I am subscribing to multiple events, then I would pass an array of event_id as parameter. For some condition, I will add an event to the array. So each time I add an event, do I have to restart the subscription?

Sarah Guo
  • 301
  • 1
  • 3
  • 15
  • 1
    The sample app is a POC to show how to use the SDK, not a fully-fledged guide to integrating into the app. Thus, it maintains subscription only for the life of the view controller--as you point out, it would terminate once that VC is destroyed. In practice, you'd probably want to have have a provider that has a lifecycle decoupled from that of your view controllers. If you have more general questions, please consider starting a thread on the [GitHub repo](https://github.com/awslabs/aws-mobile-appsync-sdk-ios/issues) -- StackOverflow is really intended for code-specific questions. – Palpatim Dec 03 '18 at 16:36
  • For your second question: a subscription once instantiated cannot be modified. You'll need a new subscription for different parameters, or have a more general subscription that you filter in app logic. E.g. if you were subscribing to comments on a blog, you might subscribe to an overall comments stream, rather than one subscription per post. The particulars depend on your use case & app characteristics--again, please feel free to open a conversation on the [GitHub issues page](https://github.com/awslabs/aws-mobile-appsync-sdk-ios/issues). – Palpatim Dec 03 '18 at 16:41
  • Thanks for answering. I have posted the question on the GitHub issues pages. – Sarah Guo Dec 03 '18 at 17:44
  • @SarahGuo Can you link to your question for those of us who are still wondering about this conversation, please? – Kenneth Sep 12 '19 at 19:39

0 Answers0