Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTags returns only tags first time #97

Closed
jzeferino opened this issue Aug 30, 2016 · 6 comments
Closed

getTags returns only tags first time #97

jzeferino opened this issue Aug 30, 2016 · 6 comments

Comments

@jzeferino
Copy link

After calling getTags for the first time it always returns null.

The problem is in this lines:

https://github.com/OneSignal/OneSignal-Android-SDK/blob/master/OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java#L777

if (tags.serverSuccess) getTagsCall = true;

and after settings this flag to true it never goes to false and in the next calls it will never call the getTags:

https://github.com/OneSignal/OneSignal-Android-SDK/blob/master/OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java#L776
final OneSignalStateSynchronizer.GetTagsResult tags = OneSignalStateSynchronizer.getTags(!getTagsCall);

https://github.com/OneSignal/OneSignal-Android-SDK/blob/master/OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalStateSynchronizer.java#L698

static GetTagsResult getTags(boolean fromServer) {
      lastGetTagsResponse = null;

      if (fromServer) {
      // Never enter here after the first time.
@jkasten2
Copy link
Member

jkasten2 commented Sep 3, 2016

@jzeferino Thanks for the report. Are you calling sendTag(s) in your code as well?

From a quick review of the SDK code it seems there could be an issue where calling getTags could overwrite sendTag(s) values if they have not been synced to the OneSignal server yet.

@jzeferino
Copy link
Author

@jkasten2 your welcome. Yes I'm callingsendTag(s) too, but only after a getTags call.
Do you plan to solve this issue?

@jkasten2
Copy link
Member

@jzeferino I haven't been able to reproduce an issue where the first call to getTags would return null if there are tags already set on the user server side or client side. We already have a unit test around this behavior as well.

public void shouldGetTagsFromServerOnFirstCall() throws Exception {

Could you list the steps to reproduce the issue in detail?

@jzeferino
Copy link
Author

jzeferino commented Sep 11, 2016

Maybe my first post wasn't clear.

After calling getTags for the first time it always returns null.

To reproduce this you should call the getTags AFTER the first time.
By others words, the 2nd, 3rd, etc... call to getTags always return null due to the lines I mentioned above. Please let me know if you can reproduce it.

@jkasten2
Copy link
Member

@jzeferino Sorry I misread that, I have fixed the issue in commit c4012fe. There is now additional tests around this method call to prevent any recurrence of an issue like this.

@jzeferino
Copy link
Author

@jkasten2 thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants