I have an application in the App Store. I'm making changes to a new version (1.2.0) and when the user updates the app in the App Store, I want the app to run a set of tutorials. Running the tutorials is not a problem; it's the question of is there a method in the AppDelegate or somewhere that only gets run the VERY first time the user runs the app after updating?
I've seen this SO question iOS : Call a method just one time which points to the use of NSUserDefaults and that's great, but how would I deploy that for a specific version number and in my case?
Simply, I want to run some code that states "if user running < 1.2.0 and updates to 1.2.0, run this code, else, ignore". The same way when update an app, there's a few screens that displays only the very first time.
I'm sorry this is generic, but I'm not entirely sure where I would run this code. My storyboard has the initial root view controller set to the Tab Bar Controller. Could I set this in the first Table View that gets displayed when the user runs the app? If so, how would I go about doing something like that?
UPDATE:
In my AppDelegate didFinishLaunching, I put the following code:
NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSLog(@"Version is %@", version);
[[NSUserDefaults standardUserDefaults] setObject:version forKey:@"CFBundleShortVersionString"];
[[NSUserDefaults standardUserDefaults] synchronize];
In my Timeline Table View (the first view that gets called), in the viewDidLoad, I put:
self.appVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"CFBundleShortVersionString"];
if ([self.appVersion isEqualToString:@"1.2.0"])
{
if ([TutorialViewController hasSeenTutorial] == NO)
{
NSArray *tutorialImages = [[NSArray alloc] init];
tutorialImages = @[[UIImage imageNamed:@"TimelineTut.png"],
[UIImage imageNamed:@"Tut 1.png"],
[UIImage imageNamed:@"Tutty 2.png"],
[UIImage imageNamed:@"newtut3.png"],
[UIImage imageNamed:@"newnewtut4colors.png"],
[UIImage imageNamed:@"newtut5.png"],
[UIImage imageNamed:@"tut 6.png"]];
TutorialViewController *tutorial = [[TutorialViewController alloc] initWithImages:tutorialImages];
[self presentViewController:tutorial animated:YES completion:nil];
[TutorialViewController setHasSeenTutorial:YES];
}
}
But when I update from 1.1.0 to 1.2.0, it doesn't play the tutorial.
Any guidance would be really great with this.
Thanks,