robovm
robovm copied to clipboard
iOS Logging in to Game Center freezes seemingly because EULA needs to be shown
Ive been working with GameCenter implementation in a LibGdx game on the RoboVM backend, but I have a problem where the application hangs after entering user credentials in the View Controller presented for Game Center.
Reproduction steps/code
Basically what happens is:
- The application launches.
- After the app has initialized, the user is presented a Game Center View where he or she is prompted to enter user credentials for Apple ID.
- After the user enter the user credentials, the apple loading indicator (the little spinning wheel) spins for a while, and then the app freezes there. There is an option to Cancel logging in to Game Center, but that doesn't respond to clicks anymore. Ive attached a screenshot at the bottom of the issue to show where it hangs.
Issue details
I then went into settings and checked out if anything could be found about Game Center (Im running an iPhone Simulator of specs iPhone 6 / iOS 9.3 (13E230). I found that if I go into Game Center settings, I could see my email as logged in, and then I was prompted to accept the Game Center EULA.
After I accepted that in the settings and relaunched the app, it worked fine, and I was welcomed by a Game Center dialog sliding down from the top saying "Welcome Back Username".
An important detail here is that the user used to log in to Game Center was completely new and had never used Game Center before. If I try it with a user that has accepted the EULA in the iPhone Settings, then the login View dismisses correctly and everything proceeds smoothly.
So, the user needs to be redirected to accept the EULA in some way. Is that possible? Ive seen that you can pass a completion argument to presentViewController, which I have set to null in my code if you'll have a look at the code that follows. Or is there some other way I can use to log in the user?
The main code that Im wondering about is
iOSApplication.getUIWindow().getRootViewController().presentViewController(uiViewController, false, null);
Where Im wondering if it is possible to pass a VoidBlock as completion rather than null, which directs the user to accepting the EULA.
The full code used for authentication:
localPlayer = GKLocalPlayer.getLocalPlayer();
localPlayer.setAuthenticateHandler(new VoidBlock2<UIViewController, NSError>() {
@Override
public void invoke(UIViewController uiViewController, NSError nsError) {
if(localPlayer.isAuthenticated()) {
print("local player is authenticated");
localPlayer.generateIdentityVerificationSignature(new VoidBlock5<NSURL, NSData, NSData, Long, NSError>() {
@Override
public void invoke(NSURL publicKeyUrl, NSData signature, NSData salt, Long timestamp, NSError error) {
// TODO Auto-generated method stub
//successfully logged into gamecenter
}
});
} else if(uiViewController != null) {
iOSApplication.getUIWindow().getRootViewController().presentViewController(uiViewController, false, null);
} else {
//canceled by the user or GameCenter is disabled
print("not supported");
}
}
});
I found this code at https://reimerm.de/2016/11/integrating-gamecenter-into-libgdx-java-multi-os-engine-8/ which is meant for multi-os-engine-8, but I managed to get it to work with a few very little tweaks.
Configuration
Build Tools:
- [ ] IDEA plugin
- [x] Eclipse plugin 2.2.0
- [x] Gradle plugin 2.3.0
I don't know if the gradle plugin applies. I run the app by right clicking the ios project->robovm...->run as simulator app in Eclipse. But I have in my build.gradle 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0' and 'com.android.tools.build:gradle:1.5.0'
Versions:
Please provide the version of RoboVM, XCode and JDK used
- Robovm: 2.3.0
- XCode: 7.3.1 (7D1014)
- JDK: 1.8.0_112-b16, Oracle Java Hotspot 64-bit Server VM
- libgdx 1.9.6
Build Targets: iPhone simulator iPhone 6 / iOS 9.3 (13E230)
Originally posted at #https://github.com/libgdx/libgdx/issues/4881
Try this, I use it in my projects and it works (may be a bit outdated and require some changes to get rid of deprecated iOS versions support).
https://github.com/BlueRiverInteractive/robovm-ios-bindings/tree/master/gamecenter/src/org/robovm/bindings/gamecenter
From a first quick look the login logic conditionals follow a different order.
It didn't seem to fix the problem. Anyways it works if the user is already logged in to Game Center, so I can release just without the login prompt for users new to Game Center.
Did you try it on a real device? Maybe it's a limitation of the simulator.
I don't have this issue, the EULA pops up, I confirm it, and it sends me back into my application.
Using this https://gist.github.com/Tom-Ski/78399e09161cd967ef77cc96f82b5bfb
On MobiVM 2.3.0 release.
Sorry for thread jumping, but is there a guide on actually how to do this? I have downloaded the 3 java files in the posts above?
It's been a long time since the issue was created but I've reproduced it. The application hangs when displaying the GameCenter login when running on Simulator. It doesn't happen on real devices.
Tested on iOS 13 simulators and iPad Mini 5.
@obigu hi, do you have sample project to investigate ?
Long time, I failed to make it work so change to this https://github.com/MrStahlfelge/gdx-gamesvcs and work like a charm.