1

I would like to update an app to add a tour on first launch. I would ordinarily handle this with some kind of NSUserDefaults key. However, there are pre-existing existing versions of the app already released.

How can I trigger some behavior on first launch of the app, but only for fresh installs and not for the first launch after an update?

Ben Packard
  • 26,102
  • 25
  • 102
  • 183
  • 2
    Do the previous version of your app store any data that you can detect or save any values in `NSUserDefaults`? Look for anything that indicates the app was there before. – rmaddy Jun 17 '14 at 22:55
  • Does the app involve user credential storage of any kind? I'm referring to server-side solutions that go along with your app.. – jakenberg Jun 17 '14 at 22:55
  • No user credential storage. And nothing in NSUserDefaults that I can count on being there, though I would estimate I can identify 50% of previous users this way. – Ben Packard Jun 17 '14 at 22:56

4 Answers4

0

you can check app version via web service. and warn users to update the app. And this case, internet connection required.

Antiokhos
  • 2,944
  • 5
  • 23
  • 32
0

The easiest way is to save the current version using NSUserDefaults:

if (![[NSUserDefaults standardUserDefaults] objectForKey:@"app_version"] || [[[NSUserDefaults standardUserDefaults] objectForKey:@"app_version"] integerValue] < [[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"] integerValue]) {
    // new version detected!
    [[NSUserDefaults standardUserDefaults] setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"] forKey:@"app_vervion"];
}

EDIT Added check for user defaults existence for first update containing this functionality.

EDIT II I now understood what you really want. You'll need almost the same code I wrote:

if (![[NSUserDefaults standardDefaults] boolForKey:@"tour_done"]) {
    // present tour and that call:
    // [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"tour_done"];
    // [[NSUserDefaults standardUserDefaults] synchronize];
}
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
  • Wouldn't this need to be in place in previous versions to work? Both fresh installs and updated apps will fire this condition. – Ben Packard Jun 17 '14 at 23:10
  • There you go! You'll just check for existence of this key first. Check my update – Julian F. Weinert Jun 17 '14 at 23:13
  • This still won't work since both fresh installs and updates will both trigger the condition - both will have no @"app_version" key. I don't want to show a tour to users already familiar with the app. – Ben Packard Jun 17 '14 at 23:48
  • If you want to don't show the tour for familiar fresh installs, there won't be any way except requiring a login. – Julian F. Weinert Jun 17 '14 at 23:52
  • Its not about familiar fresh installs, I don't want to show the tour to users who already have the app installed. – Ben Packard Jun 17 '14 at 23:54
  • I still don't see how this would help. Sorry. A new install *and* a fresh update would both not have the @"tour_done" key, so both would display the tour. Only new installs should show the tour. – Ben Packard Jun 18 '14 at 00:34
  • How comes you think an update would remove your user data?! The update prevents them. That's why it's called "update" and not "reinstall newer version" :-) – Julian F. Weinert Jun 18 '14 at 00:37
  • The data would not be there in the previous versions. Remember - "there are pre-existing existing versions of the app already released" - these versions will not have the key stored. – Ben Packard Jun 18 '14 at 00:39
  • Yes. But you won't also be possible to put a check into previous versions. The previous version is as it is. So the key don't has to be there. There is no reason for the key to exist, because the previous version won't be able to check against it! – Julian F. Weinert Jun 18 '14 at 01:16
0

On launch, check for the existence of a file/persistent setting with a name unique to the currently running version. If it's not there, show the tour, then touch the file/create the persistent setting.

sam-w
  • 7,478
  • 1
  • 47
  • 77
0

The best approach I can identify so far is to first release a version without the tour but that does record some kind of flag to NSUserDefaults. Then I can hope that most existing users will update and use the app before I launch a second update including the tour.

I can combine this with @rmaddy's suggestion to look for any other previously existing settings that might have been written to increase my coverage.

This is obviously far from ideal.

Ben Packard
  • 26,102
  • 25
  • 102
  • 183