Any way to re-show Game Center login view? (Xcode) - ios

My app attempts to log the player in when it finishes loading, like good little apps should (so says Apple). But if the player chooses to cancel the initial log-in, I wanted the app to re-attempt to authenticate the player if the player taps the leaderboard button in the game. (otherwise, of course, the button couldn't do anything if the player is not authenticated)
Unfortunately, after some research I discovered that Apple does not seem to allow an app try again to re-authenticate the player after the player cancels the first time, until the player exits and re-enters the game. (If the player cancels three or so times, Apple goes aggro and disables Game Center from the app on that device entirely. Even logging into Game Center from the stand alone app won't help after that point.)
Is there any way around this so that my app can attempt the authentication both when the app loads, and any time the player taps leaderboard button while not logged in? Or do I just have to have my leaderboard button display a message when not authenticated saying that Apple's being dumb and overprotective and not letting my app respond the way it should? (Perhaps not quite in those words...)

I've used an alternative approach that might solve your requirement. When they tap on the leaderboard, check the Game Center connection state.
If it is not GCPConnectionStateEnabledFully then throw up an alert like this "Error connecting to Game Center. Please make sure you are signed into Game Center and check your internet connection". Then inevitably they will leave your app to check and when they return the Login prompt will appear a few seconds after they return to the app.
Testing note: When you are testing these scenarios you might cancel the login prompt 3 times. If you do that it will stop prompting you altogether and you need to reset all settings in the Settings app. I remember this being really frustrating.

Related

How to check if there are Chartboost Rewarded Ads available to display?

In my Swift iOS game I have a button that I show after the player loses, this button shows a rewarded ad from Chartboost.
The problem is that sometimes, i get an error on ad retrieval (error code 6) which is "No Ad Available". So i'm running out of ads for my region, i don't know why. Sometimes i'm able to watch 2-3 ads and that's all i can watch per day.
So when im running out of ads, the button still stays there of course, but does nothing. It might be confusing for the users to press the button and not see anything happening.
So i wanted to check if there are ads available, just hide the button.
The method i'm using to check if there is an ad available is:
Chartboost.hasRewardedVideo(CBLocationDefault)
But this somehow, is returning always false, no matter what CBLocation I use.
And I trigger the showAd() like this:
Chartboost.showRewardedVideo(CBLocationDefault)
Any suggestion?
Thanks.
What region are you currently located in? Chartboost might have some trouble filling ad requests if you happen to be located in a country like Pakistan or Thailand. It may be a simple case of not having enough advertisers in your area that meet your publishing criteria.
Also, are you trying to show an ad right away on your application's bootup or is it ingame somewhere?

Objective C - Detect if finger is held on screen at app startup

I'd like to perform an action when the user has their finger held on the screen when my app startups.
To give an example: When the App launches and the launch screen is showing up, the user has a finger on the screen as long as the first ViewController appears. When the first ViewController gets into the viewDidAppear() function, I want to detect, that the users finger is on the screen and perform an action, like f.ex. jumping straight into the lastest received email. Basically this is supposed to be a kind of shortcut to an main action.
Is there any method to detect an already laying finger on the screen? To be exactly I'd like to check for the tap in viewDidAppear()
Unless the nature of Time has changed since the last time I checked, your app cannot detect what the user was doing before the app launched. The app, ex hypothesi, was not running at that time. And the mere presence of a finger on the screen during app launch will not generate a touch event that the app can detect.
The system can detect it, however, since is running before your app launches. That is why Apple added force-touch Shortcuts (for appropriate hardware). The only way you can do what you're asking is to rely on that API. Hardware that lacks this feature will simply have to do without this feature.
(After all, this is how Apple makes money: by trying to make users jealous of hardware they don't have, so that they buy new hardware. You would want to rob Apple of its income by reading this feature backwards onto old hardware, even if you could, now would you?)

GameCenter - check previous login before calling handler?

My app uses Game Center. I try to log the user when the VC loads.
If he was previously logged - great, it logs him in with the notification on top. If he wasnt logged in - great, it shows the Game Center login VC.
However, i want not to 'jump' on the user with the Game Center login VC when he enters the app. I want to have a button that brings up the Game Center login VC, which is easy to do, so only when he clicks the button, the Game Center login VC will come up.
The problem is - i discovered (through trial and error), that if i try to log the user in, and it fails (for example, the user was not logged in to Game Center at all), and if i dont bring the Game Center login VC at that moment - within the first call of the handler - i cant bring it up later on.
I'll explain - I implemented the button i talked about, which brings the GC login VC up. if i dont try to automatically log the user in on load, the button works as expected. But if i do, and it fails (for whatever reason), the button will not bring the VC up no matter what.
observations -
this shows that this is indeed Apple policy.
trying to bring the GC login VC up after failed handler login doesnt work at all, not related at all to VC appearance.
I found this question here on stackoverflow, but could not find my answer there.
My questions to you are:
Is that intended that you can only call the handler once per app run (Even though VC was not shown at first handler call)?
Is it possible to do what i asked? if so - how? I would love to able to try to login without showing VC only if i know it will succeed, so i can 'save' the handler call for the button that shows the GC login VC. I know that the information is available in the handler (according to this), im wondering if there is another way.
To conclude my questions - Do i have to 'jump' the user with the
login VC the moment i try to log him in? (if there is a GC logged in
user on the device, a VC is not required)
I hope this was clear, since its a confusing situation.
Sorry for the long post!
Thanks alot for your time!
You keep some NSUserDefaults like 'userHasAttemptedToUseGameCenter'. It starts as NO or undefined, which to you means NO. Then when they press the game center button you set to YES and try to do the game center authentication. From then on every time they open the game (or at least every time they go to a game center related screen / feature, then you do game center authentication.
Even when its working fine because you have a game center user it can be a pain because the 'Welcome back' game center banner will pop down and cover the top part of your games UI for the first few moments.
If you just let the game center authentication come up every time but the user doesn't want it, I think after 3 failed attempts to authenticate iOS will NEVER show the authentication again. Your user will then be totally stuck if they change their mind later and want to use a feature that needs game center. You can detect that case only because game center won't authenticate! And all you can do then is tell the user to go to the Game Center app and log in there. Its hell to test. If one of your test devices gets into this locked out state you have to do a 'Reset all content and settings'.
Please someone chime in if this has gotten any better in iOS8.

Loading state of in-progress game in iOS

One of the iOS games that I really like (Fieldrunners 2) allows user to continue his/her game even after the app is killed mid-level (during game play). When the user launches the app again, it asks whether the user wants to continue the in-progress level.
How are they doing this? WHat is the easiest and smartest way (cocos2d and ios) to reload an in-progress game? It seems to me that there are so many states that need to be saved. Is it as tedious as I think it is?
EDIT:
When I say killed, I double clicked the home button and then I pressed and held on the app's icon and click the x icon.

How to show game center authenticate login alert multi times?

I'm building a game and I want to make game center something like the app High Moon. Which is when authenticating, when Apple's game center login alert shows, if the user tap cancel, I will show an alert, when my alert dismisses, I want to show Apple's game center login again. This means if the user doesn't login to game center, he can't play the game.
The problem is that,when I call authenticate method to show the login alert again, Apple's game center login alert doesn't show. Someone know how to show it again? Thanks.
Actually you can't.
And the interesting part in this, if the user presses cancel three times in a row, the dialog won't appear again. Ever. Even if you have the authentication code called, the user has to go to the game center app, login, then come back.
Source: GameKit Docs.

Resources