Allow me to describe my situation:
I want to develop a game, that is round-base, and pay-to-play. That means you pay one coin, for one round of game, like Pinball etc.
The problem is, when there is interruption, ideally the game should pause, and resume whenever the user desires. Implementing that seems to be a challenge. Say my game was put into background, I would save the game state in ApplicationDidEnterBackground. However the game may or may not get terminated while in the background. So the next launch could be a "fresh start" , or, a "resume from last saved state".
If the app is left in the background long enough, say 1 week, its almost certain that other apps fighting for memory will cause the game to be terminated at some point. When the user starts my app again, they would be playing from a new round, meaning that the previously unfinished game, is gone.
From a customer point of view, this is unfair.
What I can think of is, to implement it so that whenever my app is brought to the foreground, I would go check if there was a saved game. If there was, I shall resume it instead. This poses a security issue:
Saved game, either in most primitive plist format or other formats, are persisted, and poses security problems. (What if players edit the game state and score 10 million points as top score... etc)
Are there any recommended ways to tackle these problems?
I see some Apps simply give up on saving the game, and a new round will be started on resume. Those are not paid to play games, otherwise I can imagine users getting very angry.
I have seen some Apps that saves the game state for a while, but when it got terminated, when next launched, it will start a fresh round. Which seems just as unacceptable in the case where players actually paid money for the round.
And when taken into account the possibility of crashes, I cannot come up with a good solution that ensure paying customer will get to play a full round of game. It would really help me if someone with relevant experience could share their thoughts, and how they make their decisions.
Why not tie the round finishing to the payment? If the round doesn't finish, no payment is taken. If the user's credits are insufficient at the time the round finishes, you could give them the option to purchase more credits immediately (via in-app purchase) to finish the current round.
That simplifies your task as a developer, and also provides a way to prompt the user for additional payment in a non-obnoxious way.
Here's a great tutorial on using NSCoding to save game states. It won't have any problem with the player going in a editing the file, as it is done in NSCoding. If a user REALLY wants to figure out how to un-encode the file and change the contents, which is crazy, you could do some kind of encryption on the data BEFORE you write it to file, so there would be no way the user could change it. Hope that helps!
Related
I want the specific behaviour from my apple watch, i am developing a Fitness app in apple watch.
Problem:
When user will be on some specific screen (e.g. Download ODRs from firebase). user faces issue that when user slightly down their wrist and Screen goes deem and Refresh rate goes to 1 FPS. Client has special requirement that Screen should not go to Sleep When that particular downloading process is running.
References(Example):
I tried to find solution everywhere and found some questions also over StackOverflow about this but there also saying not possible so i still haven't found anything related to this but i have found one example that is doing this behaviour is Apple watch app Mindfulness. When user runs this app and start the session as much time user will be on that screen watch will not go to inactive state no matter user raise the hand or lower down the hand.
i want to implement that same behaviour in my app. Client wants no mater what ever it takes make it work. (No issues with battery life also or Computation). i may need to implement this kind of behaviour in other screens as well.
I have tried one solution that is to Turn on auto Rotate so that when user slightly turns their wrist it will rotate instead of going to Sleep or inactive state, but it isn't the solution and looks like something weird behaviour
I have also tried TimelineView() but it will be useful once watch goes to inactive state and also it is useful when doing computations but if i have to update UI it will only do it at 1FPS in inactive state no matter how frequent your data is updating.
Thanks in advance :)
There are two decisions to make timers, with "update:" and with actions.
But i need a timer that could continue even if the player close the game.
So when player comes back to game after a certain time, his progress could be saved. Could i use CFAbsoluteTime to make this?
You should look at the Date/Time instead of in-app timers for this purpose.
Essentially, you need to track the time passed between launches of the app. You can do this via storing the Date in the user defaults when the app is closed, and comparing it to the current Date when the app is openened the next time to figure out how much time has passed.
You may want to look at using an external clock, like grabbing the time from a website, this will prevent people from simply changing there clocks to alter time. (This will not however prevent people from altering the DNS to go to there own web servers, but will most people go through that trouble for a simple game)
I'm about to add highscore support to my mobile game and I have a basic understanding problem with leaderboard services like OpenFeint or Apples Game Center:
Suppose I'm logged in to OpenFeint and/or Game Center with my account. Then a pal of mine wants to play, I hand him my device and he gets the best score ever. Is there any way he can get his score listed under his name now? My understanding is that he can't, because when the game is over the score is saved, and it is automatically saved for the current account, which happens to be mine at that moment. Tough luck.
This would mean that if I play the game with my pal in turns we would constantly have to log in and out from both services after each game to get it right in the case that one of us gets a highscore. That seems a bit awkward...
Do I overlook something or is this just the way it works? Or do I have to take care for this situation as a developer? Or do the OpenFeint/GameKit SDKs handle this automatically somehow?
I don't know about Open Feint, but at least for Game Center I think the answer to your question is: Yes, that's just the way it works. Even if you know the Game Center id's for both you and your friend, you don't have the ability to save stats for anyone but the logged in game center player.
It does seems possible that they could have supported this use case, to allow more than one player to be "signed in" on a given device, and then the game could just present a "PlayerA", "PlayerB" button to choose who's playing, instead of having to run the Game Center app to do the switch. But I imagine this use case wasn't a super high priority. (They'd rather have each of you playing on your own devices. And in fact some services like ScoreLoop keep things simple by enforcing a single player per device, period.)
imagine there is no internet connection when user is playing. The score cannot be submitted to game center. However I save the highscore on the phone using NSUserDefaults too.
So when the user plays next time and is connected to game center should I sync this score he achieved playing "offline"?
Is that a good practice?
Per the Apple Game Center docs, the answer is YES.
Make Sure Your Game Sends Data Again After a Network Failure
When you implement leaderboards or achievements, your game reports a
player’s scores or achievement progress to Game Center. However,
networking is never perfectly reliable. If a networking error occurs,
your game should save the Game Kit object and retry the action again
at a later time. Both the GKScore and GKAchievement classes support
the NSCoding protocol, so your game can archive those objects when it
moves into the background.
Set up a cache that keeps your score data (I use NSUserDefaults) to preserve data between sessions, and every so often (like, each time the user enters the app) test to see if Game Center is reachable, and if so, upload your cached scores. Let me know if you need any code - this post is pretty old, so I won't be surprised if no one ever answers :)
Also per the Apple docs for iOS 5.0 and later network error related issues are handled by a background reporting task so the developer does not need to write anything to handle this if not supporting previous iOS versions.
(from GKScore Class Reference for method reportScoreWithCompletionHandler:)
If the error is a network error and your game is running on iOS 4.3 or earlier, your game should periodically attempt to report the progress until the score is successfully reported. On iOS 5.0 and later, the background reporting task automatically handles network errors on your game’s behalf.
I am not sure what is supposed to happen if no one is logged into Game Center at all though (no network related/ submission issues) when a high score is achieved and then someone logs in later. In that case no GKScore object can even be created because there is no authenticated player and so there is no way to know who actually achieved the score whenever the next person logs into Game Center. Seems handling logged in (even without a network connection temporarily) is best practice but if no one is logged in at all and a high score is gained then it's just tough luck because it is not known who earned it, other than saving it as a device high score. If anyone handles that case then please tell.
Good question.
In my point of view, if a user is offline and is still playing, the score he/she scores should be saved locally. And when he/she again appears online, the offline score shouldn't be submitted online. Because if offline score is submitted, the purpose of making the game online is defeated.
First ,this is my friends idea ,girls always use cell phone talk too much
every month they receive the billing will cost them a lot of money
they ask me is there any applications to calculate how long they dial out a month
or maybe can pop up a alert to notice them time is up,please hang up the phone
maybe 3 mins or 5 mins (some telecommunications provider offer free talk at first 3 mins )
So.......is it possible to use application to record your talking time and give you a notice ?
I'm just a new iphone programmer ,I have no idea about this ~
Even if this is impossible , still can share some information to me
It's help me to answer my friend
thanks :)
Using the wireless company's website would be the simplest way. If you really wanted a native iPhone app that would track time you could probably write one that utilized iOS's new multitasking abilities.
Essentially, the 10,000 foot view of the app would be something that a user would launch before making a phone call. When launched, they could start a timer (or delayed timer), move the app to the background (by tapping on the home button on a iDevice that supports background apps). The app's timer would continue to run in the background while the user makes their phone call.
I believe phone calls can be moved to the background as well, so users could go back to the app and check how much time they've been on the phone call.
Complicated, but doesn't require jail breaking. The implementation could be improved a ton, but that's the 1 minute, proof of concept, that you seemed to be looking for.