Post

Replies

Boosts

Views

Activity

playerID deprecated, but teamPlayerID does not seem valid to use
I discovered the Game Center playerID has been deprecated in iOS 13.0 and we should use teamPlayerID or gamePlayerID instead. I started to play around with teamPlayerID value since Apple indicated in most cases we would be using the teamPlayerID value.A) Once a match has been created, the teamPlayerID can be obtained for each player by looping through each player in the match (myMatch).for player in myMatch.players { print("teamPlayerID = \(player.teamPlayerID)") }B) The teamPlayerID can also be obtained by calling the GKPlayer.loadPlayers(forIdentifiers:) function to obtain all player information. You can then loop through the player information to obtain the teamPlayerID for each player.(Note: Creating the player map array using $0.teamPlayerID does not result in any data being returned)let playerIDs = myMatch!.players.map { $0.playerID } as [String] GKPlayer.loadPlayers(forIdentifiers: playerIDs) { (players, error) in ... for player in players { print("teamPlayerID = \(player.teamPlayerID)") }Issues Found:1) If Player1 performs (A) and (B) then they will notice the teamPlayerID values from (A) are not the same values as the ones from (B)2) If Player1 performs (A) and Player2 performs (A), then both players will have different teamPlayerID associated with them both? Meaning ...Player1 sees a different teamPlayerID value for Player2 than Player2 sees for themselvesPlayer2 sees a different teamPlayerID value for Player1 than Player1 sees for themselvesAs a result of these two issues, it does not seem the teamPlayerID value can be used to uniquely specify a particular "player" in Game Center. I confirmed one player cannot send data to another player since both players do not have the same teamPlayerID values that represent each player in the match. (Note: The same issue exist for the gamePlayerID value as well)How can we use teamPlayerID to associate with a specific player in a match, when each player in the match has different teamPlayerID values for the players in the match?
1
0
1.2k
Mar ’20
How to prevent 2 players from joining a match together?
PLEASE HELP. I found a big problem :>(I just discovered a real big problem with my game logic involving how players are joined together into a match and I am hoping someone can help me resolve itRequirements for my applicationA player can either HOST a match or FIND a match to join. (Note: The HOST player sets all of the game options such as number of players, number of rounds, number of cards, etc..)Every match created must have only "one" HOST player onlyAll players who request to FIND a match (ie: non-host players) must ONLY join a match which is being hosted and not have a match created between themselves, which does not include a host.Example:Player1 is hosting a 2-player match and is actively searching for one more player to join the match. At this time, two separate players (non-host players) each make separate requests to FIND a random match to join. Sometimes, I see a match is created between the two non-host players, while the HOST player keeps spinning looking for a player to join.Question:How can I ensure all non-host players only join a match which is being hosted, instead of creating a match between themselves?My existing application match logic:1) When a player requests to HOST a match (eg: 2-player match) then the following match request is made, which will result in the GKMatchmakerViewController window being displayed so players can be located to fill the match slots: let request = GKMatchRequest.init( ) request.minPlayers = 2 request.maxPlayers = 2 request.playerAttributes = 0xFFFF0000 <-- represents HOST player (see note below) let mmvc = GKMatchmakerViewController.init(matchRequest: request)Note: The 0xFFFF0000 playerAttribute value ensures multiple HOST players, who are actively searching for players for their match, are not joined together into the same match. Basically, if the match already has a player with attribute 0xFFFF0000, then another player with attirbute 0xFFFF0000 cannot also join the same match.2) When a player requests to FIND a match (eg: 2-player match) to join then following the match request is made to programmatically find a match: let matchRequest = GKMatchRequest.init( ) matchRequest.minPlayers = 2 matchRequest.maxPlayers = 2 matchRequest.playerAttributes = 0 <---indicates player is NOT A HOST and can join any match available GKMatchmaker.shared().findMatch(for: matchRequest, withCompletionHandler: ...)In my 2-player non-host "Problem" described above, I understand why the two non-host players create a match between themselves. They are both requesting to find a 2-player match while both have player attributes set to "0". Is there a way to make non-host players only join a game with a HOST player?
8
0
860
Mar ’20
How to clean up match when canceling a findMatch request?
In my application, the player can HOST a game or can JOIN(FIND) a game randomly.The HOST player calls the function below to create a match with min/max players. This results in the "GKMatchmakerViewController" being displayed where the HOST can then select "Play Now" to find other players automatically. When all players are found and the match is created, then the "didFind match" function (below) is called. findMatchWithGKMatchmakerVC(minPlayers: Int, maxPlayers: Int) matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch)The player who wants to JOIN(FIND) a match calls the following function to find a match to join. When the match is located and the match instance is provided, then the completion handler of this function is called. GKMatchmaker.shared().findMatch(for: matchRequest, withCompletionHandler: )After a player requests to JOIN a match, my application allows the player the option of "canceling" the match in case they want to stop waiting. If the player cancels their request, then I need to ensure the current game environment is "cleaned up" properly so if the player then decides to make another JOIN request then their request will work. I have seen when a player requests to JOIN, then cancels, then re-requests to JOIN, then the active GKMatchmakerViewController will not find the player at all. This makes me think that I did not "clean up" my previous JOIN request properly/fully.I am performing the following to "clean up" the game environment when a player cancels their JOIN match request.1) When the call to find a match has been made but the "matchrequest completionHandler" has not been called yet (ie: no "match" instance provided by Game Center yet), then I call the following to cancel the match request only: GKMatchmaker.shared().cancel( )2) Otherwise, when the "matchrequest completionHandler" was called already (meaning a "match" instance was provided by Game Center), then my application calls the following to disconnect from the match only myMatch.disconnect( )QuestionDo I need to do anything else to properly clean up the Game Center match request in my game environment?
2
0
536
Mar ’20
Looks like Game Center matchmaking is down (not working)
Clicking the "Play Now" button on the GameCenter Matchmaker ViewController results in an extremely fast "Error Failed to find players" window popping up. Also clicking the "Invite Friends" button does not display any of the friends, but rather the GameCenter ViewController does nothing.It would be great if someone else could confirm whether they are having the issue or whether this is somehow some unknown issue with my application all of a sudden.
3
0
564
Mar ’20
Scrolling through TextView contents causes flickering and sometimes crash
My card game application has a TextView inside of a ScrollView and uses the TextView to display the scores for each player in the game for each round played The TextView is populated with with multiple lines of text string data (see example below). Round Player1 Player2 Player3 Player4 Player5 Player6 9 3/2 10 1/2 20 0/3 10 3/1 13 4/0 10 3/3 13 8 4/1 14 2/3 23 1/3 10 4/3 13 2/2 22 1/1 21 7 1/1 24 2/2 33 3/2 13 4/2 14 1/2 25 2/2 32 6 etc.. 5 etc.. 4 etc.. 3 etc.. 2 etc.. 2 etc.. 3 etc.. 4 etc.. 5 etc.. 6 etc.. 7 etc.. 8 etc.. 9 etc..After appending a new text line into the TextView, I resize the TextView (width and height values) so each line can be seen on its own line to avoid any word wrapping from taking place. The ScrollView.contentsize is then set to the TextView.frame.size. This allows the text in the TextView to be scrolled left/right and up/down for viewing.ISSUEWhen the TextView is populated with 40-50 lines of text (each having about 100 characters), then the text display will start to flicker on/off quickly when scrolling is occurring. If I keep scrolling up/down or left/right while flickering is currently occurring, then the flickering will get worse and the full TextView display starts to disappear/reappear/disappear/reappear (worse than just flickering) until eventually the app crashes.During my testing, when the TextView only has 12 lines of text (each having about 100 characters), I can constantly scroll left/right/left/right/etc. without any flicker for a while, however, eventually (after scrolling left/right/left/right for about 20 times back and forth) then flickering starts to occur. Once the flickering occurs then the flickering is constant until I stop scrolling left/right. If I stop scrolling for 10-15 seconds then start the left/right/left/right scrolling again then the scrolling works fine until I scrolled back and forth about 20 times again, then flickering starts up again. I cannot get it to crash with only 12 lines of text in the TextView. To get it to crash I need about 40-50 lines of data in the TextViewWhen flickering occurs, I see MANY MANY of the following lines displayed in the simulator debug window: CoreAnimation: failed to allocate ###### bytesIn the case where a crash eventually occurs, I see the following in the debug window as well: malloc: can't allocate region securelyWhy would a TextView inside of a ScrollView start to flicker when populated with only 12 lines of text (100 characters per line)? This does not seem like a lot of data. Any ideas what is going on and how I can potentially fix this issue?This issue is seen on my real iPhone and logs were obtained when it was connected to the Xcode simulator. If I simply run my application in the simulator only (not using a real iPhone) then I do not see the flickering occur.
1
0
1.3k
Mar ’20
How to send/receive non-ascii string
My game uses Game Center and is required to send and receive "data" between all players in the game.I convert my game data text string (ie: textStr) into byte data using the code below. I then send the byte data out. var byteData = Data.init() byteData = textStr.data(using: .ascii)!When the byte data is received, I convert the byte data back into a game data text string (ie: receivedStr) using the code below: let receivedStr = String(data: didReceiveData, encoding: .ascii)!The game data text string I am sending includes the player's Game Center "displayName" value. It just occurred to me that the Game Center "displayName" value might not be completely made of ascii characters. If this is true, then the code used to convert my game data text string into byte data (see above) will crash since a non-ascii character will be encountered.Question:How can I convert a text string, which might include non-ascii characters, into byte data so it can be sent/received successfully?
2
0
1.7k
Mar ’20
URL for a privacy policy?
I am a first time developer who created a card game which I now want to submit into the AppStore. Apple Connect indicates I need to add a mandatory Privacy Policy URL. I am not familiar with URL stuff so really have no idea what this involves. Perhaps someone can describe what is needed at a high level just so I can understand better?1) How does one go about getting a URL? Does this mean I have to pay for my own website?2) How does one associated a privacy policy on a URL?
4
0
16k
Mar ’20
Is it possible to test different iPhone models in simulator with real iPhone8 ?
I have an iPhone 8 and can use it to start a two player match using the Xcode simulator and my Iphone 8 to test my application. This works fine. I now want to test other iPhone models in two player mode. IssuesI select a different iPhone model in the simulator, start my application in the simulator and then host a 2-player match. I use my iPhone8 to join a 2 player match but Game Center never starts the match. I noticed I can only establish a 2-player match successfully if the simulator is set to "iPhone 8", which is the same model of my physical iPhone I have available for testing1) Does the simulator only allow testing with the exact same iPhone models only for some reason? Or perhaps there is a setting somewhere which will allow different models in the simultor to be used?2) I also downloaded the 12.4 simulator for the iPhone8 into Xcode so I could test that my applicaiton works on iOS 12.4, however, I cannot establish a 2-player game using my iPhone8 which is at 13.3 iOS version. Does Game Center allow players of different iOS versions to play together?
7
0
1.6k
Mar ’20
After Invite is clicked then how to launch view controller from didAccept?
I am using two real iPhones (A and B) to test game center "Invite" logic and I am getting confused.I use iPhone-A to start my game and then launch the GKMatchmakerViewController. I then select the "Invite Friends" button and select a friend to invite (which is iPhone-B).On iPhone-B, I receive a popup message asking whether I want to join the game. After I click the popup message, I see my game is launched on iPhone-B. At this point, I assume the player( player: didAccept invite:) function would be called on iPhone-B automatically and then a GKMatchmakerViewController should be created by providing the GKInvite object by calling the function below: let mmvc = GKMatchmakerViewController(invite: inviteToAccept) mmvc!.matchmakerDelegate = self viewController.present(mmvc!, animated: true, completion: nil)Where does the "viewController" comes from to allow me to present/display the GKMatchmakerViewController?Can someone explain how they present the GKMatchmakerViewController when the didAccept function is called?
11
0
1.5k
Feb ’20
How can you use Xocde debugger when testing Invites?
I understand the simulator cannot be used to send an game Invite to an iPhone. As a result, I have two real iPhones which I am using. How can I see the logging generated from the iPhone that receives the Invite? This iPhone does not currently have the application running when the Invite comes in, so is there a way to have an iPhone connected to the Xcode debugger before the application is even woken up due to receiving an Invite?
4
0
624
Feb ’20
iPhone with lower iOS version cannot be added as a friend to Game Center
My son has an iPhone 6 which is stuck at iOS 12.4.4 since it is no longer supported I guess. My iPhone is at iOS 13.3.1. When I go into my Settings/Game Center and try to add him as a friend, he receives a IM message asking if he will be my friend. When he clicks on it, a display pops up indicating he must upgrade to iOS 13.3 to accept the friend invite.1) Is there anyway around this so I can add my son as a "Friend" in Game Center?2) Most importantly, will I be able to "Invite" my son into a match using the GameCenterMatchMaker view controller when my game is completed? If it matters, the "Deployment Info" for my game in XCode indicates a "Target = iOS 12.4" . I assume this means my game will be allowed to be downloaded by any iPhone having iOS 12.4 or greater ?
0
0
430
Feb ’20
It seems like Game Center is sending same data twice
Is it possible for Game Center to send the exact same data to the same player twice?I am frequently (not all of the time) noticing, the same exact data being received twice, which is causing issues in my application.I am using the following functions in GameKitHelper to send and receive data in my application:func sendDataToPlayer(data: Data!, gkPlayer: GKPlayer) { var playerArray: [GKPlayer] = [ ] playerArray.append(gkPlayer) do { try myMatch?.send(data, to: playerArray, dataMode: .reliable) } catch { } } func match(_ match: GKMatch, didReceive data: Data, forRecipient recipient: GKPlayer, fromRemotePlayer player: GKPlayer)I am experiencing the same exact data coming into the "didReceive data:" function with the exact same data, recipient and player valuesHas anyone seen this duplicate data issue before?I see this issue when testing with 2 real iPhones and the simulator (ie: 3 players). I do not see this issue when testing with 1 iPhone and the simualtor (ie: 2 players).As a side question .... what is the difference between:1) match(_: didReceive: forRecipient: fromRemotePlayer:) and2) match (_: didReceive: fromRemotePlayer:)
1
0
511
Feb ’20
What is a responsible time to connect to a Game Center match?
Based on the game options within my game, which are selected by the player, there can be multiple types of matches the player could join which have the required "number of players" but also share the same "player group number". I am calling "findMatch()" for each different match type one by one, however, I would like to know what a reasonable time would be to wait for Game Center to determine if there is an actual match in which the player can join. When there is not a match available for the game type I am currently searching for, then I cancel the match request and move on to search for the next type of match, via a new findMatch() call and so on.Would waiting 10 seconds for Game Center to determine if a match exists be reasonable before starting a new "findMatch( )" request in Game Center?
4
0
603
Jan ’20
loadChallengableFriends( ) error on iPhone 6 (iOS 12.4.4)
I am using the following method to obtain a list of GameCenter "friends" and it returns a list of player names on my iPhone 8 ( iOS 13.3 ) loadChallengableFriends(completionHandler: )When this method is called on an iPhone 6 ( iOS 12.4.4), I get the following error relating to the "loadChallengableFriends( )" method loadChallengableFriendsWithCompletionHandler:]: unrecognized selector sent to instance *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GKLocalPlayerInternal loadChallengableFriendsWithCompletionHandler:]: unrecognized selector sent to instanceI was informed the iPhone 6 models no longer receive updates from Apple so this iPhone 6 is stuck at iOS 12.4.4 version.Since the loadChallengableFriends( ) method works on the iPhone 8 (iOS 13.3) and does not work on the iPhone 6 (iOS 12.4.4), I was thinking perhaps this method does not exist in iOS 12+The Apple documentation indicates the following for all of the "friends" methods I could find:a) loadChallengableFriends( ) SDK iOS 13+b) loadFriendPlayers( ) SDK iOS 8.0 - 10.0 (deprecated)c) loadFriends( ) SDK iOS 4.1- 8.0. (deprecated)Questions1) Do I interpret the "SDK iOS 13+" statement to mean the loadChallengableFriends( ) method does not exist before iOS 13?2) What method do we use to find "friends" between "iOS 10 and iOS 13" then ? Perhaps this is not supported durine that time?
0
0
382
Jan ’20
How to assign constraints to a Scrollview which covers part of the screen only?
I want to use a Scrollview on the middle 2/3 of the screen so I did the following:1) I added a BaseView UIView to the middle 2/3 of my MainViewController and set the constraints to the following:leading =0trailing =0top to safe area = 150bottom to safe area = 1502) I added a MyScrollView inside the BaseView and set the constraints as follows:Note: All MyScrollview constraints remain RED after setting these constraints :>(leading = 0trailing = 0top = 0bottom = 03) I added a MyDataView UIView object inside the MyScrollView . The MyDataView starts at (0,0) and has a size of 500x500. I tried setting constraints on MyDataView to the following values but the top and leading constraints remain RED, most likely because the MyScrollView constraints are RED (see 2 above)top=0leading=0width=500height=5004) In the viewDidLoad function I added the following:ScrollView.delegate = selfScrollView.contentsize = MyDataView.frame.size5) I added various objects (buttons, labels, etc.) in the MyDataView UIView and tried to set constraints on these objects but the constraints are all RED as well. Questions:1) I am setting up the ScrollView properly so it can be used for 2/3 of the screen area only?2) How can I set valid constraints for the objects placed in the MyDataView and have them be a nice BLUE color?
20
0
14k
Dec ’19