Android Google Play TurnBasedMatch- Not a valid turn status: 4 - google-play-games

I have been working on developing a turn-based multiplayer game. Everything had been working fine for quite a while, until suddenly I can no longer open the intent for the "Match inbox" (eg,
Intent intent = getGamesClient().getMatchInboxIntent();
startActivityForResult(intent, MainActivity.RC_LOOK_AT_MATCHES);
When I look at the error's stack trace, it is because there is a match with an invalid state.
What's worse, is that even when I try to load the matches to simply delete/dismiss them all programmatically, I also get the error:
02-05 07:43:36.684: E/AndroidRuntime(13814): FATAL EXCEPTION: main
02-05 07:43:36.684: E/AndroidRuntime(13814): Process: com.oakonell.ticstacktoe, PID: 13814
02-05 07:43:36.684: E/AndroidRuntime(13814): java.lang.IllegalStateException: Not a valid turn status: 4
02-05 07:43:36.684: E/AndroidRuntime(13814): at android.os.Parcel.readException(Parcel.java:1473)
02-05 07:43:36.684: E/AndroidRuntime(13814): at android.os.Parcel.readException(Parcel.java:1419)
02-05 07:43:36.684: E/AndroidRuntime(13814): at com.google.android.gms.internal.fc$a$a.a(Unknown Source)
02-05 07:43:36.684: E/AndroidRuntime(13814): at com.google.android.gms.internal.ex.a(Unknown Source)
02-05 07:43:36.684: E/AndroidRuntime(13814): at com.google.android.gms.games.GamesClient.loadTurnBasedMatches(Unknown Source)
(It looks like the constants for the MATCH_TURN_STATUS_* run from 0-3, so 4 is invalid.)
Besides the fact that the API somehow allowed me, in ignorance, to save a match in an invalid state, it appears that once there is one in an invalid state, it can't ever be referenced, even if to clean it up.
I saw that the developers console references an API to reset matches for a (whitelisted) user.
https://cloud.google.com/console/project/[app id]/apiui/api/gamesManagement/method/gamesManagement.turnBasedMatches.reset
But I couldn't get this to work from within the console itself (I was also uncertain how to specify the user(s)). Is there a way to access this from the Android app code? Otherwise, how would I access from the Console to reset the matches for the (tester) players affected by this invalid match?

I was able to "disconnect" the app, deleting all google data, from my user.
Go to Device Settings | Accounts | Google.
Click on Google+, choose the user with the broken match under account settings, click Apps with Google+ Sign-In, choose the app with the broken match, and finally click disconnect.
When the dialog comes up to confirm, check the "Also delete all your (App) activities on Google, and click Disconnect to confirm.
This didn't immediately seem to fix the problem, I also cleared the devices' "Google Play Services" cache. Go to Device Settings | Application Manager, find "Google Play services" and click it. For this App, clear data/cache, Manage Data, whatever you can to delete all local cached data (I don't think this can harm any other apps using Google Play services, as you should be able to eg, install the app on a new device and have it sync to your cloud saved state. OK, perhaps this could delete pending changes that haven't been sent to the cloud yet... use with caution.) This one may not have been required to perform in order for my user's "match intent" to work again, but as I say, it didn't seem to immediately work after the app disconnect, and relogging in. It either took time for the disconnect to propagate across the cloud(?) or I also had to clear the device's cache...
Now to hope that I don't someone save any matches with an invalid state, in some manner.
This solution certainly beat waiting the two weeks that I thought was my other option, waiting for the match to expire after no activity from the two users.
(I suppose a third option for how this was fixed was that some "cleanup" job was ran on the google servers to delete/correct any invalid matches, either periodically or in response to either this stackoverflow question or an email/crash report I sent when my device's "Google Play services stopped responding".)

Related

Windows: Detect in Registry when a user is logged in but disconnected

When I log in into an windows device, I can sometimes see 2 users sessions (I can see it by clicking Task Manager -> Users). One of the users has status Disconnected and the other active
Is there a way for me to see weather the user is disconnected or not in the registry?
Thank you
I don't know if there is a registry value you can check and if you find one it must be considered an unintended side effect you should not rely on.
The WTS API is the correct way to handle this.
Call WTSRegisterSessionNotification to receive notifications and/or WTSEnumerateSessionsW to find the current sessions and their states.

FSEvents Directory Watcher for remote server volume / only works for locally initiated changes, not remote updates?

Scenario:
I am using FSEvents to monitor local watch folders successfully.
Using the same FSEVents code to monitor a directory that is within a mounted volume from a remote server over say, AFS (/Volumes/example) successfully notifies my FSEVents callback for any files the local client changes, but not changes made by other users on other machines - even though I do see those changes reflected immediately in the Finder.
Heres my FSEvents implementation: DirectoryWatcher.m
What I expect to happen:
Any updates the Finder sees, my FSEVent tooling or any other appropriate API would detect those changes and notify my app. When changes are made by any user they appear in any other users Finder, and my app would notify callbacks of changes.
What actually happens:
Client machine Bob mounts volume 'example' from Alice's server
Bob makes changes to any subdirectory within 'example', and bob's file watcher app (my app :) ) notifies immediately of changes. Yay!
Now Fred logs into Alices server and mounts the 'example' volume, and makes changes. Fred is notified - Yay. Bob is not. Boo. Also, Fred is not notified of changes that Bob makes. Boo.
Also, if Alice makes changes directly on the server, neither Fred nor Bob has FSEvents triggered - even though in all cases, the Finder immediately is aware of changes and updates file listings and icons upon any changes.
Questions:
Anyone have any pointers about notifications of file system events on remote servers? FSEvents is near perfect save for this one gotcha. Is polling the only option?
I imagine AFS/SMB protocol has notification tooling for clients that changes have occurred - but those changes are not on the file system level and this FSEVents is unaware. IE: Finder knows because it is tapped into the protocol event stream, not just the file system event stream?
Is this even possible without polling?
Note, I am testing on 10.13 through 10.11.
Thank you!

bad internet connection and PFQueryCollectionViewController

I was testing my app and I noticed this error message popping up from the PFQueryCollectionViewController:
2015-07-06 21:40:58.445 Noms[320:29335] [Error]: The Internet connection appears to be offline. (Code: 100, Version: 1.7.5)
2015-07-06 21:40:58.446 Noms[320:29335] [Error]: Network connection failed. Making attempt 2 after sleeping for 1.604623 seconds.
This was expected, since my phone was not connected to the internet. However, I want to detect this error and handle it myself, rather having the endless loading scroll on the screen. Looking at the documentation didn't yield any variables that I thought could be useful.
Does anyone know how I might receive this callback so I can handle them?
Parse provides a "cancel" method on all PFQueries, including the one in PFQueryTableViewController. In theory, you could cancel your query after a timeout of your choosing. Unfortunately, many developers are reporting a bug in that method that prevents it from working.
My best recommendation recommendation is to check for internet connection before firing your query. Apple's Reachability project is a great tool for this.

Locations while in background

Sorry if this one's a bit of a stupid question.
I'm currently building an iOS app which needs to be able to have (or acquire) the user's location when a push notification is received, potentially waking up the app. Previously, I was just monitoring significant location changes, updating a property as locations were received, using the last acquired location when the push notification is received (the location doesn't need to be very accurate, within 0.5-1.0 km will suffice).
However, with the highly annoying changes to location permissions in iOS8, this now requires 'always' authorisation - which repeatedly prompts the user about the access, greatly increasing the chances it will be turned off altogether. So my question is basically twofold. Will 'when in use' authorisation allow the location to be accessed even when the app is in the background, woken up by a push notification? And if it will, is there anything special I need to do to get the location - for example, wait a few seconds for the GPS to acquire a position, or make a call to enable location monitoring?

0 failed to match payload to <Name-of-notifier> notifier

I am trying to send push notifications on an iOS device from the APIGEE console on web. It suddenly started giving me this error: 0 failed to match payload to notifier
Solutions I have tried without success:
- deleting and recreating notifier
- deleting and recreating notifier with new .p12 certificate
- deleting and recreating notifier with a different name
- registering from device using a different device push token and checking to see if its device specific
There is 0 information on the Internet about this error code. Hope somebody can help!
Thanks!
Generally with notifiers you should name them according to the platform you're targeting. This is either "android" or "apple".
As we've found, this has solved your current problem, though it may be a red herring anyway if the service wasn't responding at that time.
There is a rolling 5 minute cache for notifiers. Did you try again after 5 minutes?

Resources