Post

Replies

Boosts

Views

Activity

Reply to Game Center SwiftUI Implementation
There are lots of tutorials explaining how to set up Game Center in itunesconnect and configuring it for your application in Xcode. But, the missing part for me to use Game Center from SwiftUI was that it is just too easy! This view will authenticate the user and show their avatar once they authenticate. import SwiftUI import GameKit struct MenuView: View {     let localPlayer = GKLocalPlayer.local     func authenticateUser() {         localPlayer.authenticateHandler = { vc, error in             guard error == nil else {                 print(error?.localizedDescription ?? "")                 return             }             GKAccessPoint.shared.isActive = localPlayer.isAuthenticated         }     }     var body: some View {         NavigationView {             NavigationLink(destination: GameView()) {                 Text("Play Game")             }         }         .navigationViewStyle(StackNavigationViewStyle())         .onAppear {             authenticateUser()         }     } } Obviously, this is not production-ready code but it may help you to get started with SwiftUI and Game Center
Jul ’20