Is there any way to know in my app when it was opened from the AppStore? and also was updated?
I need to know how can i debug this or better yet simulate the opening of the app from the store.
Thanks.
Is there any way to know in my app when it was opened from the AppStore? and also was updated?
I need to know how can i debug this or better yet simulate the opening of the app from the store.
Thanks.
Use openUrlMethod
to findout whether app is opened from appstore or not.
Below is the the method in AppDelegate
that will be called when app opened from any other app.
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
//Get URL Scheme here from url.scheme and compare whether it matches with default URLScheme of appstore or not
}
To find out whether app is already UpToDate or not, Get the app version from bundle and get the app version in AppStore and compare.
Here is the link to Check If App has new version or not
You can check if the app was opened for the first time.
In the func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
method in your AppDelegate
you can test some persistent flag:
if !UserDefaults.standard.bool(forKey: "wasOpenedBefore") {
//the app is opened for the first time - do what you need
UserDefaults.standard.set(true, forKey: "wasOpenedBefore")
}
The value will be there as long as the app is installed. If user deletes it and installs again you will see it as a first time opening. Basically, it satisfies your requirements to know if the app was opened after being downloaded from AppStore.