I've been looking for this information through Apple documents, but could not find the answer. Soon after I launch my Game Center app there is a pop-up that says:
Welcome back, PlayerName
How can I hide the "Welcome back, playerName" message from Game Center when the player authenticates?
Heres a shorter version for Swift:
//Call it right after create this object:
let localPlayer = GKLocalPlayer.localPlayer()
suppressGCBanner(0, originalWindowCount: UIApplication.sharedApplication().windows.count)
////////////////////////////////////////////////////////////////////////
static func suppressGCBanner(iteration: Int, originalWindowCount: Int) {
let windows = UIApplication.sharedApplication().windows
if windows.count > originalWindowCount {
let window = windows[1]
if window.respondsToSelector("currentBannerViewController") || window.respondsToSelector("bannerSemaphore") {
print("Found banner, killing it \(iteration)")
window.hidden = true
return
}
}
if iteration > 200 {
print("suppressGCBanner: timeout, bailing")
return
}
runThisAfterDelay(seconds: 0.02, after: {
suppressGCBanner(iteration + 1, originalWindowCount: originalWindowCount)
})
}
static func runThisAfterDelay(seconds seconds: Double, after: () -> ()) {
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC)))
dispatch_after(time, dispatch_get_main_queue(), after)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With