ios sdk swift : Show in-app app update/install prompt

41 Views Asked by At

Does anyone know what Api are used to achieve this. In the below image we a prompt appears that allow us to install/update another app. This seems to be native and it has same behavior as the the in app purchase

enter image description here

1

There are 1 best solutions below

0
Andrew On

You want to use StoreKit, specifically SKOverlay

You can read more about it here

In UIKit in the UIViewController where you want to show it you can use the following code:

func displayOverlay() {
    guard let scene = view.window?.windowScene else { return }

    let config = SKOverlay.AppConfiguration(
        appIdentifier: "The iTunes identifier of another app.", 
        position: .bottom
    )
    let overlay = SKOverlay(configuration: config)
    overlay.present(in: scene)
}

In SwiftUI you can use it in the following way:

struct ContentView: View {
    @State private var presentingAppStoreOverlay = false
    var body: some View {
        Button {
            presentingAppStoreOverlay.toggle()
        } label: {
            Text("Show SKOverlay")
        }
        .appStoreOverlay(isPresented: $presentingAppStoreOverlay) {
            SKOverlay.AppConfiguration(
                appIdentifier: "The iTunes identifier of another app.",
                position: .bottom
            )
        }
    }
}