So, releasing the LibGDX game for iOS using Admob and GPGS or other bindings is a painful process, but I managed to get everything that works, and my game is now waiting for the review state. At the time of this answer, it appears that Apple rejects applications using Google Play Game services because the GPGS SDK logs the user into Safari to log in. This is unacceptable to Apple because it is a "bad user interface." In fact, when a user tries to log in, the GPGS SDK looks for a Google+ installation to log in if it cannot be found , and then the Chrome browser will open, and finally Safari if Chrome is not installed. After correctly integrating GPGS and trying to present my Apple binary, I ran into another issue related to the Google SDK not signing up. Since it looked like my application was rejected, even if I fixed this problem, I decided to cut the GPGS and use the Apple Game Center instead. However, I could still get GPGS with Admob running on my test device so that I could answer like here.
First, the samples in BlueRiverInteractive are not all that are useful for playing LibGDX. All UIWindow, UIViewController, and UIView elements that you do not need to contact. The IOSLauncher class should extend the delegate instead of the UIApplicationDelegateAdapter. If you look inside the Delegate, it will take care of configuring UIApplication, UIWindow and other iOS things for your application. When you expand it, you will be forced to implement createApplication (). This is mine, for example:
@Override protected IOSApplication createApplication() { final IOSApplicationConfiguration config = new IOSApplicationConfiguration(); config.orientationLandscape = false; config.orientationPortrait = true; config.useAccelerometer = false; config.useCompass = false; iosApplication = new IOSApplication(new SplishGame(this), config); return iosApplication; }
Store iosApplication as a member of the field of your IOSLauncher class. Thanks to this, you can get UIWindow that you need to show interstitial announcements and leaders / achievements.
Secondly, make sure your IOSLauncher class overrides didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) instead of the didFinishLaunching method with only one parameter, otherwise it will not be called. In your didFinishLaunching method, you can create an instance of your GPGS manager class (moreover, within a second) and try to log in silently. What reminds me of another problem that I encountered when trying to integrate GPGS - make sure you use the GPGS manager object to make life easier (PlayServicesManager). There are two examples in the GPGS bindings project, and I first looked at a "hard to use" one that does not use the PlayServicesManager class. After you set up your manager object, you can call simple methods like manager.login () or manager.getLeaderboards () to accomplish what you need to do.
To initialize your manager class in the didFinishLaunching method, do the following:
playManager = new PlayServicesManager(); playManager.setClientId(CLIENT_ID); playManager.setUserDataToRetrieve(true, false); playManager.setViewController(iosApplication.getUIViewController()); playManager.didFinishLaunching();
For Game Center, itโs like this:
gcManager = new GameCenterManager(iosApplication.getUIWindow(), new GameCenterListener() {...(overridden methods left blank) gcManager.login();
Then the code from your main project can call the necessary functions through your ActionResolver interface - or what you called your native interface. This way you will have stuff like:
@Override public void getLeaderboards() { log.debug("Showing all leaderboards."); playManager.showLeaderboardsPicker(); }
And everything should work.
Another thing that you apparently need to do (for GPGS only) is to copy this method to the IOSLauncher class:
// copy-paste this to your app delegate. @Override public boolean openURL(UIApplication application, NSURL url, String sourceApplication, NSPropertyList annotation) { return GPPURLHandler.handleURL(url, sourceApplication, annotation); }
So about this, as far as I remember. Please write if you think that something is wrong, or I forgot something important.