HomeiOS Developmentios - The way to current the brand new Sport Middle dashboard...

ios – The way to current the brand new Sport Middle dashboard from inside a SwiftUI app


The Sport Middle Dashboard can be opened via the system Entry Level. It behaves like a system overlay, and Apple tied the presentation to the Entry Level being lively in the mean time you name set off(). Trick is while you flip the Entry Level on for a second, name set off(), and as quickly because the system begins opening the dashboard, you instantly flip it off once more. Due to that, the floating bubble by no means seems, however the Dashboard nonetheless opens usually.

import SwiftUI
import GameKit

struct ContentView: View {
    var physique: some View {
        VStack(spacing: 20) {
            Button("Login Sport Middle") {
                GKLocalPlayer.native.authenticateHandler = { vc, error in
                    if let vc {
                        UIApplication.shared.connectedScenes
                            .compactMap { $0 as? UIWindowScene }
                            .first?.home windows.first?
                            .rootViewController?
                            .current(vc, animated: true)
                    }
                }
            }
            
            Button("Present Dashboard") {
                let ap = GKAccessPoint.shared
                ap.isActive = true   // enabled so set off will work
                ap.set off {
                    ap.isActive = false   // disable instantly so the bubble will not seem
                }
            }
        }
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments