How to maintain app settings when user updates to new version - iphone

When we update an application, the settings which are selected by the user in the old version should be kept after updating to the newer version.
Let me explain this with an simple example:
Version 1.0 of my app has a switch that is ON by default but the user can set OFF. In the App Store I am going to publish next version— 1.1—with some modification but it also has the same switch. When the user updates it from the device the switch value should stay OFF.
How can I achieve this kindly reply me with your valuable comments...
Thanx in advance...

You can simply use NSUserDefaults
App 1.1 can easily read what App 1.0 wrote.

When you update your app to a newer version, then the UserDefault have no change (If dont remove app).
Then what we have to do is detect whether your app is updated to a newer version. What I did in my app is maintain a variable in UserDefault like "CurrentAppVersion", then when app is launched I check the currentVersion which getting from app Bundle, if they are difference and up, then I migrate my settings to a new version and update "CurrentAppVersion" to a new version also.
Reference:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *currentAppVersion = [userDefault objectForKey:#"CurrentAppVersion"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
NSLog(#"current version: %#, appversion: %#", currentAppVersion, appVersion);
if ([currentAppVersion isEqualToString:appVersion] == NO) {
// Your app has just updated to new version, migrate your app settings.
} else {
// NO, do nothings with your app settings.
}
Hope it help your much, :)

The contents in Application Documents directory and Library directory will not change after app update. So what you should do is just write the settings (say a string "SWITCH:YES") to your Documents directory just like
[string writeToFile:<#(NSString *)#> atomically:<#(BOOL)#> encoding:<#(NSStringEncoding)#> error:<#(NSError **)#>];
see this post Retaining data after updating application

Your 1.1 version just needs to read the saved user settings written by the 1.0 version. This is one reason that putting a versioning mechanism in your saved user data is a good idea, to make this type of upgrade simple.

for sure you are saving your switch value some where on your first version so you can get it and apply it in the next version .. for me when I make update to an app I usually build a backward computability class inside it I retrieve all the user settings and content and call it for the first time the app run and then I apply the old settings on the new version. Good luck

Related

NSUserDefaults and Update an application from app Store

In my app I'm using NSUserDefaults to store user data, when upgrading to a new version from App Store will those values be saved or deleted/ rebooted?
(for example: [prefs setInteger:_numberOfTimesAppOpened forKey:#"openApp"]; if before the upgrade the value is 70 after the upgrade will the value be 70/ 0/ or non existent?)
in case these parameters are deleted what is the right approach to save user data so it will be saved even when upgrading the application?
another question is if there is a way to store information on the device so if the user delete the app and then re-install it his previous data/ profile can be set?
Everything that is stored in UserDefaults will be still there after an update. They are persisting. User defaults will get deleted when the app is removed from the device by the user.
And there is no way to store if an app was installed already once. At least not on the device.

Remove feature in submitted App

I currently have an App on the App Store with features a, b, c, d
I am looking to make features c and d paid for using in-app purchasing in the future but until that is all programmed/implemented; also restrict or remove (visible) access to those features. Note anyone that had previously setup c or d will maintain access to them.
Is it ok to remove features like that in a submitted application?
I would try to use your applicaion's version for that purpose.
Three steps to follow:
Detect the app's first launch Link for first time app launch
and at that moment you save your version number Link to get app's version number
once you intend to display a feature do something like
NSString *currentVersion = #"1.2.0";
NSString *versionAtAppDownload = #"1.1.5";
if ([currentVersion compare:versionAtAppDownload options:NSNumericSearch] == NSOrderedDescending) {
//decide what to do
}
This should be added in your next app version. Once done, everybody who already downloaded your app should have saved their current app version.
Now your update to your next bigger version i.e. 1.2.0, this version will be the one that hides content for users that have not yet paid. The users who downloaded your app at any previous version should be able to still see everything.
Something like this should work, good luck!

iOS - Prompt User to Update to Latest App Version

Is there any method or plugin available that will alert the user to upgrade an app if the version they are using is not the latest? I suppose I could ping a web service to check what the current version is and compare with the user's version and go from there. As an aside, is there a way to check the current version of the app (some property I don't know about) or do you simply have to hardcode the version as some float variable or something?
Thanks
There's a nice little open source library available called Harpy that will accomplish this for you! It provides the ability to check for updates on startup, daily, or weekly, and it uses itunes to do the checking, so config is really minimal.
you will need to build the update check functionality yourself. however you can get the version info from the app.
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
Bear in mind tho that just because you have an app up. and it has been released into the store. that does not mean the app is immediately available to all users via the app store.
There is update version of harpy called siren that will help you. Below is the link,
https://github.com/ArtSabintsev/Siren
You'll have to build such a solution yourself. There's no update-checking functionality provided by the iOS SDK.
Most apps just check a website or similar, as you've already considered.
You can grab the version from the info.plist with
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
self.applicationVersion = [infoDict objectForKey:#"CFBundleVersion"];
self.applicationBuild = [infoDict objectForKey:#"CFBundleShortVersionString"];
And, yes just hit a web service. Or even easier you could just put a file up on S3 and update that with your version number.

check and update an application through code when a new version is available in appstore

Within my application, I want to check if there is any updated version of my application is in the app store. If there is any, then have to inform the user through an alert message and if he/she opt for upgrade I want to update the new version.I want to do all this through my application. Is this possible?
You can store the most current application version string on your server. When the app is activated, request this information from the server and compare it to the version string that is contained in your applications Info.plist.
You can get the version in Info.plist like this
[[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"]
If the string differs, you can show an alert that a newer version is available in the app store. You can also link directly to the app store from the alert.
You could do something like this: let's say you just started making an app. You hardcode its version (1.0) inside the app's configuration file or something similar.
Then, you can use an universal xml configuration file, which is read by the app everytime it starts and connects to the internet. Inside that xml, make a field named "lastest_version", where you set that value.
When the app starts you can check the xml. If your hardcoded value is 1.0 and inside the xml you get 1.1, this means you need an update.
This is how we do it and, just like Philippe said, we also use an plist to store the original version value.

iPhone app Update Vs new version

Let's say I have an existing IOS app live on Appstore which is version 1.0
Now I make some changes to the app and want to submit back.
Are there 2 separate ways to submit ?
Like can I still keep the version as 1.0 and just submit the app OR
I need to create a new version 1.1 and then submit it ?
What are the differences in the process?
Also from the customer end, how does this work for new/existing users ?
I have just discovered something about version upgrades and the App Store. Just now, I'm suffering issues and users crashes because of a behavior of iOS system that I can't figure before. And, very important, iTunes, AppStore and iOS have modified some upgrading and installing rules in last versions. Now, it works this way:
- When user install a new version, all the files in the bundle are downloaded and copied in the previous existing bundle, but OLD FILES OR COMPONENTS ARE NOT DELETED (or not all are deleted). So, the final bundle IS NOT equal to the bundle of a fresh installation of the new version.
- For example, if a xib/nib file is localized to different languages for the new version, the updated bundle will include both versions: the one in the root folder and the other one in each localized folder. The system, obviously, will use the first one and only a fresh installation will show localizations for that file.
One of my apps shows that issue with MainWindow.xib and as there are some modifications in references and classes, the updated apps crash each time you try to run as it is using a obsolet object. I have built a new version changing the name of the xib/nib files that have been localized. As MainWindow is one of them, I have to modify the reference in info.plist of course.
OK, knowing that, you can build a new version with complete different components in the bundle that, if files of previous version does exist, the app then offers the user the option of using them. That is, two versions of the app in a single icon and bundle. Not very difficult to do.
BUT, the very weird thing is that I think that new iOS version and iTunes don't allow downgrades. I have tried to do it but didn't get it done. That is, if you install a version, for example 1.2, it is impossible AFAIK to install latter v1.1 on the device nor in iTunes->"Applications". So, the double version bundle will live until a reinstallation of the app.
You need to create a new version number, which makes sense since this is a new version of your app. This will then appear as an update for your customers. I don't think you can upload a new binary with the same version without removing the old one from the store.
You add a new version in iTunes connect, then update the version number in Xcode to match and create a new archive. It's pretty straightforward.
You must always increase the version number of any update to your app.
Users will see a badge on the App Store icon on the device, and in iTunes on their PC. Going into the updates section, it will list your app along with the list of changes you've provided, and a button to install the update. They can also update all apps at once.
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
NSLog(#"version is%#",version);
You do not have to open version numbers to submit any longer. Open up Xcode, go to Window - Organizer - Archives and Distribute an app you have created successfully.