0

I want to track the app launch source.
I check UIApplicationLaunchOptionsURLKey in application:didFinishLaunchingWithOptions: to know how the app be launched
but i don't know the value of UIApplicationLaunchOptionsURLKey when app is launched from app store. Does anyone know?

how i track launch source:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        if let launchOptions = launchOptions {
            if let url = launchOptions[UIApplicationLaunchOptionsKey.url] {
                //wake from other app
                //the problem is i don't know the value of "url"
             }
        } else {
            //wake from desktop
        }
}
nullLululi
  • 194
  • 1
  • 7

1 Answers1

0

I think you will need to look at the sourceApplication key:

https://developer.apple.com/documentation/uikit/uiapplication/launchoptionskey/1623064-sourceapplication

From experimentation with my own app that launches (through a custom protocol) another app of mine, I see that the sourceApplication value contains the bundle identifier of the source app.

So, for your case, I expect that it would be:

com.apple.AppStore

See: What is the bundle identifier of apple's default applications in iOS?

But I don't know this for sure.

Commentary: It's probably not good to rely on this sort of stuff because the OS could change to invalidate this assumption. But I don't really know your use case.

Daniel
  • 8,794
  • 4
  • 48
  • 71