The following page explains how to manually show the Add Friend Sheet for GameKit. However, in SwiftUI apps, UIViewControllers aren't used and I can't get the Add Friend sheet to work. What is the most simple way to show the presentFriendRequestCreator from a SwiftUI app?
https://developer.apple.com/documentation/gamekit/connecting_players_with_their_friends_in_your_game?changes=_6
// Below is the code that shows how to present the add friend sheet, the problem is that I don't have a rootviewController to pass into the function as I'm using SwiftUI.
do {
try GKLocalPlayer.local.presentFriendRequestCreator(from: rootViewController!)
} catch {
print("Error: (error.localizedDescription).")
}
0
0
1.3k