-1

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • What do you mean by opening app from app store ? –  Apr 24 '17 at 08:55
  • Do you want to know whether the App Store app triggered the start of your app (as opposed to, say starting the app via Finder or Spotlight)? – DarkDust Apr 24 '17 at 09:09

2 Answers2

0

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

Community
  • 1
  • 1
Sivajee Battina
  • 4,124
  • 2
  • 22
  • 45
0

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.

Max Pevsner
  • 4,098
  • 2
  • 18
  • 32