If the iOS SDK doesn't have functionality for this, then what if I have a basic (static) website, and somewhere on that website I manually set a piece of data that specifies the latest version of my app in the app store every time I release an update? How can I make my app query the website for that version data and check it against the version running on the iOS device?
Open the Settings app on your Android device. Open the "Applications" and/or "Application Manager" section. Tap on your app to select it. The App Settings Panel has multiple options including App Version, Notifications, and Location.
Android shows the version number for every app in the "Apps" settings menu; All you need to do is open the list, tap the app you want, and scroll to the very bottom. On iOS and iPadOS, the equivalent of that would be going to the app's preferences via Settings –> [App Name], as seen in Option 1 below.
Open the App Store. Tap your profile icon at the top of the screen. Scroll to see pending updates and release notes. Tap Update next to an app to update only that app, or tap Update All.
You are on the right track. You need to make an HTTP request to your static version web page. To do this you can use an NSURLConnection object. So something like:
NSURL * url = [NSURL URLWithString:@"http://yourweb.com/version.txt"];
NSURLRequest * request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];
_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
Then in your delegate implementation:
(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSHTTPURLResponse*)response
{
if(response.statusCode != 200)
// you got an error
}
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
{
// again with the errors ...
}
// you got some data ... append it to your chunk
// in your case all the data should come back in one callback
- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
{
[mData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// your request finished ... check the version here
}
So in your connectionDidFinishLoading you have a look at mData that you have collected. Parse out the version number and compare it to your bundle version number:
[self infoValueForKey:@"CFBundleVersion"];
You can make a query like http://itunes.apple.com/en/lookup?bundleId=com.easi6.doorsndots to AppStore.
Returning JSON has an version information (currently on AppStore) which can be compared the other in bundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With