gpt4 book ai didi

ios - Game Center 未经身份验证,在 iOS 12 中请求身份验证

转载 作者:行者123 更新时间:2023-11-28 07:33:18 25 4
gpt4 key购买 nike

swift 4、iOS 12。

使用 Game Center 记录游戏中的高分。一切正常,假设用户登录到游戏中心。我可以检测到他们什么时候没有,但不能完全弄清楚在这种情况下如何打开 Game Center。

func ask4GameCenter() {
let myAlert: UIAlertController = UIAlertController(title: "Attention", message: "Log into Game Center to record High Scores", preferredStyle: .alert)

myAlert.addAction(UIAlertAction(title: "Ignore", style: .default, handler: { (action) in
self.gameOn()
}))
myAlert.addAction(UIAlertAction(title: "Logon", style: .default, handler: { (action) in
UIApplication.shared.open(NSURL(string: "gamecenter:")! as URL, options: [:], completionHandler: { (success) in
if success {
self.gameOn()
}
})
}))
self.view?.window?.rootViewController?.present(myAlert, animated: true, completion: nil)
}

最佳答案

好的,我找到了答案。

func ask4GameCenter() {
let myAlert: UIAlertController = UIAlertController(title: "Attention", message: "Log into Game Center to record High Scores", preferredStyle: .alert)

myAlert.addAction(UIAlertAction(title: "Ignore", style: .default, handler: { (action) in
self.gameOn()
}))
myAlert.addAction(UIAlertAction(title: "Logon", style: .default, handler: { (action) in
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: { (success) in
if success {
self.gameOn()
}
})
}))
self.view?.window?.rootViewController?.present(myAlert, animated: true, completion: nil)
}

关于ios - Game Center 未经身份验证,在 iOS 12 中请求身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54009233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com