My favorites | Sign in
Project Logo
pxl
                
Search
for
Updated Aug 20, 2007 by kai.cherry
Labels: Featured, Phase-Implementation
Shimmer  

iPhone Class for auto update pxl package support

Introduction

Many apps have a rapid update cycle as they are being developed. Shimmer is a lightweight iPhone app class that allows app developers to add auto update features to their current apps with very little code.

Details

Shimmer, an 'homage' to Mac OS X's "Sparkle" is designed to allow app devs to easil add OTA updates of pxl packages to their applications.

You decide where the update comes from in the code to help ensure your users that they are getting "the right and intended" version.

Shimmer allows your app to display an alert informing the user that an update is avalable, with a version number and a short description. Should they choose to download it, download progress is displayed and your update is passed on to the PXLPackage daemon to do the install.

If your users aren't using pxl, the class simply ignores the check for update request. Its designed to be unobtrusive and "low work and maintenance" on your part :)

Implementing Shimmer in your iPhone Application

Shimmer is very easy to implement. you can do it in a few lines of code.

Here is a Step by Step guide:

1. Import Shimmer.h and the Foundation.h header (if your aren't already) into your UIApplication subclass:

#import <Foundation/Foundation.h>
#import "Shimmer.h"

2. In your UIApplication subclass, make an NSThread instance to run the update routine. This way if there is net congestion or a server problem, your app can keep running without blocking the phone looking for the update. You can copy and paste this code verbatim. A good place to do this is in the - (void) applicationDidFinishLaunching method, after your initial UI is all set up.

Form 1:

[NSThread detachNewThreadSelector:@selector(checkForUpdates:) toTarget:self withObject:nil];

Form 2

[NSThread detachNewThreadSelector:@selector(checkForUpdates:) toTarget:self withObject:aView];

In the above line of code (Form 2), aView is the name of the view object you want the alert to appear over. Set this to whatever your topmost active view is. This is to assure that your alert isn't obscured.

if all of your content is in a single main view, use Form 1.

Then, add this new method to your UIApplication subclass. You can copy and paste this in as well. You'll need to plug your actual url into checkForUpdateHere: of course...

-(void)checkForUpdates:(id)anObject{
	NSAutoreleasePool *peeIn = [[NSAutoreleasePool alloc] init];
        Shimmer *updater = [[Shimmer alloc] init];
	[updater setUseCustomView:YES]; //you must add this if you specify a view for the alert to appear over
	[updater setAboveThisView:anObject]; //you must add this if you specify a view for the alert to appear over

         if(![updater checkForUpdateHere:@"http://kaisakura.org/update.xml"]){
	//this user doesn't have pxl installed or there is no update, so drop it
		[updater release];
	}else{
		[updater doUpdate];
	}
	[peeIn release];
}

3. You'll need an update description file on your server. It looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>appVersion</key>
	<string>1.1</string>
	<key>description</key>
	<string>A test update for you! Adds nothing</string>
	<key>pxlPackBytes</key>
	<integer>201899</integer>
	<key>pxlPackURL</key>
	<string>http://kaisakura.org/test.zip</string>
</dict>
</plist>

update.xml is an ascii or binary plist. There are 4 keys that are used:

appVersion: the version of the app on your server. description: a short description of what your update adds, or anything the user should know. pxlPackBytes: the size in bytes of the download pxlPackURL: the link on your server to the pxl. Most servers don't recognize the .pxl extension, but if you have configured yours to, then .pxl is fine. This must link to a valid .pxl package.

The class then checks to see if the phone has the PXL system installed. If it does not, it returns NO and your app can continue doing its thing.

If the update info can't be retrieved, or the appVersion key in your app's Info.plist is the same as the one in update.xml the class also returns NO. Its meant to be as passive and non-intrusive as possible.

If an update is available, the user will see an alert like this over your app's dimmed ui:

Shimmer will return YES or NO depending on the user's choice.

4. . Shimmer will at this point put up a "Downloading.." alert with a progress indicator so the user knows what is going on.

Upon completion, your app will quit as the PXL System installs the update and Springboard is restarted.

The new version is ready for the user.

License

Shimmer is free to use in any kind of app whatsoever, open or closed source, assuming the license you are using allows for the following:

1. Please attribute the project in your documentation. The notice is in the Shimmer.h header. Its not neccessary to do so in your app if you don't want to.

2. Please don't change the Shimmer class. If you need to add functionality, consider a subclass. Your subclass is your own...make a million if you can ;)

3. If you need to fix something in the Shimmer class, just give us the fixes so it sucks less for everyone else too.

4. That none of the above cannot be superseded by any other license you choose to use.

If you need some other terms for the Shimmer class...let us know. You can download the class in source form from the Downloads section.


Comment by e...@litman.org, Aug 25, 2007

Awesome! But the source doesn't seem to be anywhere here.

Comment by chiragpatel1984, Sep 15, 2007

what do i use to put shimmer in my iphone

Comment by chiragpatel1984, Sep 15, 2007

what do i use to put shimmer in my iphone

Comment by namjam105, Feb 09, 2008

Add Source installer : http://iphonebaidu.com/app/ Test iPhone - iPhone Simulator : http://iphonebaidu.com/test/ All Software for Apple MAC : http://iphonebaidu.com/mac-iphone/ All Software for Apple iPhone : http://iphonebaidu.com/mac-iphone/iphone.html

Install iTransformy (.swf) view for iPhone : http://iphonebaidu.com/beta/ Forum, DOwnload Themes, Apps for iPhone. http://iphonebaidu.com/forum/

Copyright © 2008 iPhone Baidu! Inc. All rights reserved


Sign in to add a comment
Hosted by Google Code