I am making a game app with game center.
I would like to ask what is the good practice for saving game data like whole object (GKTurnBasedMatch) in app?
Since, there is matchData for each of the match. I am planning to save this GKTurnBasedMatch in NSDefault , however no luck for retrieving it from the nsdefault. So, is there any good way to do so ?
Could you guys please give me some advises? my consideration is only what if i update the app , would NSDefault data be deleted after the app update?
It's not good practice to store these objects at all. The "truth" for Game Kit is at Game Center, so your app should be retrieving the latest information from Game Center to ensure everything's up to date. Imagine if your user has two different devices, and makes progress on a game on one device; if the other device is relying on shared state then it would miss out on the updates.
When your app launches, use +[GKTurnBasedMatch loadMatchesWithCompletionHandler:] to find out what matches are currently in progress. If you need to store custom data with the matches, store it in the matchData property on the match so that it's synced with Game Center.
If you want to support some kind of limited offline display, I'd take the properties you need to be able to show and store those associated with the match ID (so you can match it back to a live match when you get reconnected to Game Center. For example, you could store the match participants' names and the current message. Those are all just strings, so you could easily them with the match ID in user defaults.
Related
I am currently writing an iOS real time game app auto-matchmaking function. I really need help to find out how can the two players can interact. Specifically, when plaeryA pressed the find match button indicating playerA is looking for a match. It sends a query to Parse database and sees that playerB is is also looking for a match. Now, I want them to be matched. I know it is a very bad idea to use queries to frequently polling the data from the database to check if the player is matched or not. Is there anyway I can achieve it such that 'if A and B is matched, a notification/alert is sent to both players to wait for their acceptance, if A & B both accepted the match, then the two players would perform the segue to the game view controller simultaneously.
I googled online, all I got is that I have to either use Apple's Game Center or Google Play service. But both of them requires users login. I do not really want that because it would be tedious user experience. The user had to register and sign in the account of my app, and now they have to sign in either game center or google again.
Any advice/help is greatly appreciated!!
Is there anyway possible to implement challenges and achievements in an app without using Game Center. The current app that I'm working on is not a game, but has challenges and achievements based on photo users submit. For example if a user uploads a photo of their pet, they get 50 points for submitting that picture.
You can use that, I create a simple class for iOS game center in GitHub
https://github.com/DaRkD0G/Easy-Game-Center-Swift
I would recommend having an if statement (or something like that) set up, and whenever the user "completes" the achievement, it changes a value on your server to "completed", and adds the number of points earned from the achievement to the user's overall points. If you already have a database storing user account data, you could add fields for the achievements. Then when the app loads the "achievements" page, you could just check the server real quick and display the results.
I have a question which I have not been able to figure out so I decided to see if I can get some help on here.
I am working on an iBeacons project and I have been able to understand the basic function of iBeacons, setting up UUID'S and major and minor id's to specify exact notifications, but my question is how do I dynamically update information I send out to the users without having to go into the code each time to do this. Do I need to create a database to store all my information I want to push out to users? if so how will this database constantly refresh messages pushed out to users? An example would be lets say if you walk into a store and you get a notification in the shoe section saying there is a 10 percent off, you look at the notification but not too impressed and start to walk out, then you get another notification saying for today only you can get a 25 percent off... The app has to dynamically refresh for this to be possible.
Please help me clarify this
Thank you very much for the help
What you probably want is to store this deal information in a web service so you can update it without changing the app. Your app would need to download the updated deal information from the web service either when it starts up or when it sees an iBeacon.
My company, Radius Networks, offers a tool called Proximity Kit that makes this easy. You can assign arbitrary key/value pairs to iBeacons using a web interface. Then your app downloads them automatically an has access to them whenever you see iBeacons.
In your scenario, they key/values could be something like:
primary_offer_text=10% off all shoes
secondary_offer_text=20% off all shoes
Let's say we wan to have a custom backend for a iOS game that manages user accounts and allows the users to send objects to each other, but we don't want to actually have the user to create a dedicated useraccount for our game. It would be possible to simply use the playerID for the usermanagement, but that would not be secure. Is there any way to use a local gamecenter authentication to also authenticate at a custom webservice?
Currently i ponder about how the game 'pocket frogs' enables the players to send gifts to gamecenter friends. Gamecenter doesn't seem to provide this functionality so i assume they use a custom backend for it, but how can such a backend authenticate the player?
I can't say for sure if this is how Pocket Frogs (PF) does it, but based on the fact that only Game Center (GC) friends who also play PF appear on the neighbours list, I think it may work like this:
When a player first starts the game, they get a user id (a 32-bit int, say) from the PF back end which is stored locally. Once the player has this id it can be stored in one of the GC leaderboards under the GKScore context property rather than the value. As far as I can see, PF automatically adds every player to all of the leaderboards pretty much straight away.
Then when another player wants to send a gift, PF gets the leaderboard scores for all of their GC friends and if they have a valid score they must be a PF player and the context value can be read to get their PF id.
In this way the PF back end gets the correct id, but doesn't need to use their GC id.
Incidentally, I tried out the idea of using challenges for sending gifts, and it can work. See http://www.lrgdigital.com/ofgame.html for the game I tried it with - you have to win a game before you can gift it. It has the benefit that you can send the gift to anyone on your friends list rather than only friends who play the game, but there are some limitations as well.
No. Gamecenter uses apple id and that is off limits for obvious reasons. And if you look into the game center framework, there is a way to get gamecenter friends.
Look here to see how to get an array of friends: Game Center Friend List
I want to use Apples Game Center for players to log in to my game, but I also want to store additional gameplay related data from the players as well. I want to use the Parse.com service, so I was thinking about having the players signup/login to Game Center when the game loads, and then if it's not already been done, store the players, "player identifier" in a PFUser object on parse. That way I'll be able to store data for the player on parse.
So my question (finally) is, is that a good way to do it? I'm new to iOS so I was wondering if there are any obvious issues with that way of doing things that I'm missing?
Thanks for any advice.
It's not a bad way to do it. That way you use a unique ID for each parse user, then storing additional data in Parse is easy. The steps would be:
authenticate the user with GameCenter
login to Parse with an auto ID or username/password combination
set a new 'gameCenter ID' property for your PFUser in Parse
You'll face some data redundancy, though it's worth noting that the PFUser uniqueID is created on the server side and can't be seeded or modified on the device (not even after creation, I believe). Adding a separate field to your user database to store the GKID data will allow you to find & allocate data to a specific user in the future.
Here's the relevant page from Apple's GameCenter Documentation
Also worth noting: you can generate a PFUser with an auto ID (assuming your user has internet connectivity), which will be as useful for you when saving additional data, so you may not even need to use the GameCenter userID. This auto ID will likely persist within the app until the user a) updates the app, b) deletes and reinstalls the app, or c) follows any other login/signup process you have in the app (Parse is your friend). The primary reason for using the GameCenter ID is that it will be the same for a user across devices/app installs/updates, etc.