Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 01-31-2011, 03:34 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 8
ckyourself is on a distinguished road
Cool Automatically point users at app store when update is ready?

I've seen this functionality before; an app update is available but maybe I haven't checked the appstore.app yet. At any rate the app say foo.app will prompt you while in app and say

"A new version for Foo.app is available! Want to goto the app store and download it?" (App Store) (Later)

Clicking app store takes you to the app store to download the new update, but effectively the app itself is aware of its own updates.

I'm assuming their app simply connects over a socket and pings their server or a simple script which replys with the current version which the developers maintain, then the app can determine if/when an update is avail and notify then.

Is this how this is done? Or is there a simple way w/o having to open an external facing http/other socket to a personal webserver...

-Matt
ckyourself is offline   Reply With Quote
Old 02-01-2011, 10:12 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
paicolman is on a distinguished road
Default

Hi,

I implemented something similar in my last app, but I did it "the very dumb way"... I have a web server, in that server I have in a specific directory a file (in my case it's a PDF File, which the App tells the user being ready to download, but it could be something else)

So, the App knows the name of the file at some point in time. By sending an http request to <myServer>/<myDirectory>/myscript.php, the scripts returns the contents of that directory. The App compares the name of the pdf in that directory with the name of it's local pdf file. If the name has changed, it prompts the user. Stupid, but easy, and it works.

The drawback is: The App is always doing that small http request to the php script in the server, but the user barely notices it, and the couple of bytes flying around are not a problem.

Don't know exactly how to implement it to redirecting to the AppStore, but it could be something similar.
paicolman is offline   Reply With Quote
Old 02-01-2011, 11:23 AM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Quote:
I'm assuming their app simply connects over a socket and pings their server or a simple script which replys with the current version which the developers maintain, then the app can determine if/when an update is avail and notify then.
I'd say this is a common solution.
smithdale87 is offline   Reply With Quote
Old 02-01-2011, 03:13 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 8
ckyourself is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
I'd say this is a common solution.
Sure, Here is my solution to this.

I made a version.txt on my webpage which contains the string "1.0.3" or whatever the current version on iTunes is.

I then can use the below function in my app delegate

Code:
- (void)checkWebForNewVersion {
    
    [NSThread detachNewThreadSelector:@selector(threadedCheckWebForNewVersion) toTarget:self withObject:nil];
    
}

- (void)threadedCheckWebForNewVersion {
    
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
    NSLog(@"[UPDATE] Connecting to update server");
    
    NSData *verData = [[NSData alloc] initWithData:
                       [NSData dataWithContentsOfURL:
                        [NSURL URLWithString:@"http://lecturaapps.com/version.txt"]]];
    
    NSString *verStringNeedTrim = [[NSString alloc] initWithData:verData encoding:NSUTF8StringEncoding];
    NSString *verString = [[verStringNeedTrim stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
    [verStringNeedTrim release];
    
    if ([verString length] != 5) {
        NSLog(@"[UPDATE] Connection to update server failed. (invalid verstring length of %d)", [verString length]);
        [verData release];
        [verString release];
        return;
    }
    
    NSLog(@"[UPDATE] Connection to update server success. Version = %@", verString);
    
    NSString *localVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    
    // local
    NSMutableArray *leftFields  = [[NSMutableArray alloc] initWithArray:[localVersion  componentsSeparatedByString:@"."]];
    
    // web
	NSMutableArray *rightFields = [[NSMutableArray alloc] initWithArray:[verString componentsSeparatedByString:@"."]];
    
    while ([leftFields count] < [rightFields count]) {
        [leftFields addObject:@"0"];
    }
    
    while ([leftFields count] > [rightFields count]) {
        [rightFields addObject:@"0"];
    }
    
    BOOL showUpdateDialog = NO;
    
    for (int i = 0; i < [leftFields count]; i++) {
		NSComparisonResult result = [[leftFields objectAtIndex:i] compare:[rightFields objectAtIndex:i] options:NSNumericSearch];
		if (result != NSOrderedSame && result == NSOrderedAscending) {
            NSLog(@"[Update] User needs update");
            showUpdateDialog = YES;
            break;
        }
	}
    
    
    //NSLog(@"compared %@ vs %@", localVersion, verString);
    
    if (showUpdateDialog) {
        NSLog(@"[Update] Update needed! (have: %@, server: %@)", localVersion, verString);
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Update Available!"
                                                            message:[NSString stringWithFormat:@"Exhibit A version %@ now on App Store!", verString]
                                                           delegate:self
                                                  cancelButtonTitle:@"Later"
                                                  otherButtonTitles:@"App Store",nil];
        [alertView show];
        [alertView release];
        
        
    } else {
        NSLog(@"[Update] No update needed (have: %@, server: %@)", localVersion, verString);
    }
    
    [leftFields release];
    [rightFields release];
    [verData release];
    [verString release];
    
    
    [pool drain];
    
}

- (void)alertView:(UIAlertView *)av clickedButtonAtIndex:(NSInteger)buttonIndex {
	if (buttonIndex == 0) {
		NSLog(@"[Update] They canceled");
	} else {
		// direct them to our app in app store
	}
    
}
ckyourself is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 406
17 members and 389 guests
Brandt, coolman, fredidf, Free App Monster, givensur, iAppDeveloper, jbro, Kryckter, locombiano89, Mah6447, Meoz, simplymuzik3, SLIC, stanny, stevenkik, Tomsky, WeaselPig
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:50 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0