I am able to start a 2-player match between the IOS simluator and my connected iPhone. The IOS simulator starts hunting for a two player game using the GameKit Matchmaker View Controller and the iPhone requests a two-player match by entering my game application as well. Of course, the IOS simulator and my iPhone are using separate Game Center accounts to make this possible.I now want to test sending a true "Invite" request from the IOS simulator to the iPhone. When requesting a match in the IOS simulator, I can see my iPhone "user" is listed under the "Recently Played" section of the GameKit Matchmaker View Controller display window, after clicking the "Invite Player" button of course. When I select my iPhone "user" and then select "Play Now", my iPhone never receives an Invite request because the IOS simulator generates the following error:GKMatchmaker: invitePlayersWithRequest: - Error Inviting Players Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=GKServerStatusCode=5008, NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server., NSUnderlyingError=0x600002761c20 Error Domain=GKServerErrorDomain Code=5008 "status = 5008, missing required key: self-push-token" UserInfo={GKServerStatusCode=5008, NSLocalizedFailureReason=status = 5008, missing required key: self-push-tokenCan the IOS simulator be used to Invite iPhone users? If so, what does the error mean and how can I fix it?Does my iPhone have to be inside my game application to make this work ... I hope not.
Post
Replies
Boosts
Views
Activity
The Game Center Programming Guide clearly states real-time peer-to-peer matches supports 2 to 4 players only. However, I just notced I can call the findMatchWithMinPlayers method with the request.maxPlayers parameter set to a value of 5->16 and the GKMatchmakerViewController presents 5->16 players for me to invite.Is the Game Center Programming Guide out-of-date and real-time peer-to-peer matches support more than 4 players are now?I would like to know for sure so I can enable more than 4 player support into my game.
Do you know how the GKMatchmakerViewController handles a decline from a player (friend) who was listed in the "request.recipient" array? Does Game Center then automatically hunt for some random player or does the match request fail?
When a user is not currently in the game application, I understand Game Center with push an Invite notification to the user's device asking them if they want to play the game. If they accept the invitation then Game Center will open the application automatically on the user's device. How can the game application know it was started as a result of an accepted invitation? If this can be determined then I can place the user into the game right away and bypass any option screens, displays menus, etc. which are no longer required.
I am using Swift 4.I am able to authenticate the localplayer and find a match using the Game Center match viewcontroller. I was also able to link the iOS simulator (player1) to my real iPhone 8 device (player2) into a match for test purposes.However, after the localplayer is authenticated, I would like to obtain a list of all my game center "friends" myself and then create my own viewController interface to invite/connect players into the game. I was able to call "GKLocalPlayer.local.loadChallengableFriends( )" to obtain the friends, but I am not sure how to properly invite them to a match one by one programmatically.Googling indicates GKMatchmaker inviteHandler, GKInvite and "player DidAccept" are involved but I do not know how to put this all together.Any pointers, hints or sample code would be greatly appreciated.In the meantime, I will continue to Google around
I am able to authenticate the localplayer and find a match using the Game Center match viewcontroller. Assuming the match is going to have 4 players, I would like to ensure only 1 player sets the game options before they are matched with 3 other players. Of course, the 3 other players must know they should not set game options themselves. Any idea how this is done?
I want to click a button and have my View slowly animate into the viewing area from the right side of the screen. Then click a second button and have the view animate off the screen from left to rightI added a Button (OpenButton with IBAction = openView) and a View (DataView) into my main ViewController. I set constraints on DataView to be the safe area for top(20), bottom(20), leading(16) and trailing(16). I also added a Button (CloseButton with IBAction = closeView) into the DataView.While in Portrait mode, clicking the OpenButton results in the OpenView( ) function being called and the DataView animating properly from right to left into the visible screen as desired. Clicking the CloseButton results in the view animating off the screen from left to right as desired. (Note: There are no calls to viewWillLayoutSubviews( ) which are made by the system at this time). I can click OpenButton and CloseButton multiple times and the animation works great each time while in Portrait mode.I now switched to Landscape mode. Clicking the OpenButton results in the openView( ) function being called and the DataView animating properly from right to left into the visible screen as desired. Clicking the CloseButton results in weird animation in the wrong places and the DataView does not properly go off the screen. Debugging has shown that when the CloseButton is pressed, then viewWillLayoutSubviews() and viewDidLayoutSubviews( ) are called, then the closeView( ) function is called and then viewWillLayoutSubviews() and viewDidLayoutSubviews( ) are called a second time. When viewDidLayoutSubviews() is called a second time, then the DataView snaps back to it's origin.x constraint value of 16 which results in it moving back to the leading safe area, which affects the animation which is currently going on. It seems like that is what is messes up the animation.Debug "print" statement output <Note: OPEN button clicked here>openScoreWindow -- enter dataView.frame.origin.x = 16.0 animation complete - openScoreWindow<Note: CLOSE button clicked here>viewWillLayoutSubviews dataView.frame.origin.x = 16.0viewDidLayoutSubviews dataView.frame.origin.x = 16.0closeScoreWindow -- enter dataView.frame.origin.x = 16.0viewWillLayoutSubviews dataView.frame.origin.x = 767.0 <--- this value is set in the UIVIew_Animate( ) in the closeView( ) function, as desiredviewDidLayoutSubviews dataView.frame.origin.x = 16.0 <--- this is proof the "leading" constraint is reset back to 16 during the active animation animation complete - closeScoreWindow . <-- this is when animation has completed** I tried to replicate this scenario by creating a separate brand new swift "test project" which just had the two buttons and dataView, however, in this "test project", the animation in portrait and landscape mode works as desired since viewWillLayoutSubviews() is never called when opening and closing the view. Oh well, for some reason, in my project, viewWillLayoutSubviews() is called twice when I click the Close button.I have no idea how to get around this issue. Any ideas?override func viewDidLoad()
{
super.viewDidLoad()
dataView.isHidden = true
print ("viewDidLayoutSubviews")
print(" dataView.frame.origin.x = \(dataView.frame.origin.x)")
print("")
}
@IBAction func openView()
{
print("openScoreWindow -- enter")
print(" dataView.frame.origin.x = \(dataView.frame.origin.x)")
//ensure view is positoned out of the viewing area
dataView.frame.origin.x = getScreenSize().width + 100
//make view visible for eventual animation
dataView.isHidden = false
//animate view moving from right to left onto the screen
UIView.animate(withDuration: 1.0, //1 second
delay: 0,
options: .curveEaseInOut,
animations:
{
self.dataView.frame.origin.x = 16
},
completion: { [weak self] finished in
print(" animation complete - openScoreWindow")
print("")
})
}
}
@IBAction func closeView()
{
print("closeScoreWindow -- enter")
print(" dataView.frame.origin.x = \(dataView.frame.origin.x)")
//animate view moving from left to right off the screen
UIView.animate(withDuration: 3.0, //1 second
delay: 0,
options: .curveEaseInOut,
animations: {
//move view out of the viewing area
self.dataView.frame.origin.x = self.getScreenSize().width + 100
},
completion: { [weak self] finished in
//hide the view
self?.dataView.isHidden = true
print(" animation complete - closeScoreWindow")
print("")
})
}
I have an imageView which has a top constraint IBOutlet called imageViewTopConstraint. In viewWillLayoutSubviews( ) I set the imageViewTopConstraint.constant value. The imageView displays properly for all iPhone models while in portrait mode, which is good.When I switch to landscape mode, I want to disable the imageViewTopConstraint, so the viewWillLayoutSubviews( ) has the following code:if UIDevice.current.orientation.isPortrait {
imageViewTopConstraint.constant = (2 * screenHeight) / 3
imageViewTopConstraint.isActive = true
}
else if UIDevice.current.orientation.isLandscape {
imageViewTopConstraint.isActive = false
}IssueWhen I run the application it is initially in portrait mode. When I switch to landscape mode I receive the following fatal error at the line where I set "imageViewTopConstraint.isActive = false" to disable the constraint (line 6 above) Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional valueAny idea what is going on or what this means?
I am making an application to work on many various iPhone models in portrait mode. I would like to have a button (with fixed height) always be afixed at a position 2/3 way down the screen display area no matter what iPhone model is used. I understand I can do this by pinning two views in the storyboard and then setting Equal heights with 1:3 and 2:3 ratios, however, is there a way to do this without introducing two views into the storyabord for this purpose?
In Xcode 10, there was a button for the Object Library located left of the "inspector" buttons. After the upgrade to Xcode 11 occurred, this button no logner exists. Where did it go?