delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

How to clear all your local data and subscribe again ? #35

Closed LeNiglo closed 8 years ago

LeNiglo commented 8 years ago

Hey,

I have an app with 3 activities (Login, List, Detail of item). I need to be able to completely clean my List activity when I move back to login. At the moment, I unsubscribe during the onStop() and subscribe during the onStart() but the second time I log in, I receive nothing.

Do you have an idea ? Thanks (awesome library !)

ocram commented 8 years ago

Thanks for your question and your appreciation :)

So if you're subscribing in onStart() and unsubscribing in onStop(), you're basically toggling the subscription status whenever the app is opened/closed (e.g. via the "Home" key), right?

Can you check if this is working? Are there any things happening when the app is "minimized" and then "maximized" again?

Are you using the unsubscribe method correctly? What did you do? Keep the ID returned from the subscribe method and use that ID to unsubscribe again, later?

Can you pass an UnsubscribeListener as the second parameter, as shown in the examples? This way you should be able to see if unsubscribing works correctly or fails with an error message.

Apart from that, what about logging the user out? Does that help? You were talking about the second time you log in, so did you properly log out the user before?

If neither of those suggestions work, I'm afraid it might be a question concerning the Meteor project itself (and its DDP protocol sub-project). This library does not cache any resources, so far. So if Meteor is not sending the resources again after you've properly unsubscribed and/or logged out, you may get better help there.

LeNiglo commented 8 years ago

Thanks for you answer, I will look at it ASAP and give you a feedback ! :)