Skip to content

PSUpdateApp is a simple method to notify users that a new version of your iOS app is available!

License

Notifications You must be signed in to change notification settings

Sean-Wang/PSUpdateApp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PSUpdateApp

A simple method to notify users that a new version of your iOS app is available.

About

PSUpdateApp notifies you if a new version of your iOS application is available in the AppStore or in any other place.
If a new version is available, PSUpdateApp presents an UIAlertView, that informs you of the newer version, and gives you the option to update the application.
The component is based on AFNetworking framework, using AFJSONRequestOperation method to read and parse the JSON response.
The object is a singleton based on Matt Gallager object (More informations here).

##Getting Started

Installation

The recommended approach for installating PSUpdateApp is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation. For best results, it is recommended that you install via CocoaPods >= 0.16.0 using Git >= 1.8.0 installed via Homebrew.

via CocoaPods

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Change to the directory of your Xcode project, and Create and Edit your Podfile and add RestKit:

$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, '5.0' 
# Or platform :osx, '10.7'
pod 'PSUpdateApp', '~> 1.0.6'

Install into your project:

$ pod install

Open your project in Xcode from the .xcworkspace file (not the usual project file)

$ open MyProject.xcworkspace

via Download

Download PSUpdateApp or play with the example project. Open PSUpdateApp.xcworkspace (CocoaPods need).

Integration

PSUpdateApp has a simple integration:

  • Import PSUpdateApp.h into your AppDelegate or Pre-Compiler Header (.pch)
  • In your AppDelegate.m application:didFinishLaunchingWithOptions: create your PSUpdateApp object.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = [[MainViewController alloc] init];
    [self.window makeKeyAndVisible];
    
//--- DEFAULT MODE
//    Start in default mode with your appID.
    [PSUpdateApp startWithAppID:@"529119648"];

//--- CUSTOM LOCATION MODE
//    Start with your appID and with the store location. The default mode set the store location by the device location.
//    More information about the store code here: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
//    [PSUpdateApp startWithAppID:@"529119648" store:@"US"];
  
//--- CUSTOM URL MODE
//    You can start with a custom url, if you want to detect the version about a ad hoc distribution app.
//    [PSUpdateApp startWithRoute:FAKE_ROUTE];
    
//--- ALERT STRATEGIES
//    The strategies change the Alert buttons rappresentation
//    The Default Strategy has 2 buttons: "Skip this version" ans "Update"
//    You can set your strategy with:
//    DefaultStrategy   -> default mode
//    ForceStrategy     -> force the update. The alert has only the update button
//    RemindStrategy    -> Add the remind me button.
//    
//    You can set the strategy with:
//    [[PSUpdateApp sharedPSUpdateApp] setStrategy:RemindStrategy];
//    
//    With RemindStrategy the alert will appear after 2 days (2 is the default value) from the remind action.
//    If you want you can set the days until promt with:
//    [[PSUpdateApp sharedPSUpdateApp] setDaysUntilPrompt:10];

    return YES;
}
  • In your AppDelegate.m applicationDidBecomeActive: start detect the available app version.
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

//--- DETECT VERSION
//    Start to detect the version. In this case the block is nil, and the component use the default alert
    [[PSUpdateApp sharedPSUpdateApp] detectAppVersion:nil];
    
//--- DETECT VERSION WITH BLOCK
//    You can use the completion block to implement you custom alert and actions
//    [[PSUpdateApp sharedPSUpdateApp] detectAppVersion:^(NSError *error, BOOL success) {
//        NSLog(@"UPDATE");
//    }];
}

Custom Url

If you want to use PSUpdateApp in a distribution ad hoc, or in an enterprise app, you can start PSUpdateApp with startWithRoute: using a JSON with this structure:

{
  "results": [
    {
      "version": "1.0.6",
      "trackViewUrl": "http://paperstreetsoapdesign.com/apps/updateapp/update.html",
      "type":"mandatory"
    }
  ]
}

Use setURLAdHoc: if you want to create a stringWithFormat: between your custom url and the appStoreLocation property of PSUpdateApp.

Notes

  • This project requires ARC and iOS target from 5.0
  • Use the PSUpdateApp properties to change the PSUpdateApp default value: for example the app name or store location
  • It's localized
  • It has a simple BDD test inside the example project
  • Into the custom JSON structure, it's a new field called "type", to set the PSUpdateStrategy from remote (DefaultStrategy or ForceStrategy).

Localizations

  • English
  • Italian
  • Spanish
  • Arabic
  • Korean

Version

1.0.6

Created by:

Daniele Bogo

Credits

License

The MIT License (MIT) Copyright (c) 2013 Paper Street Soap Design

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

PSUpdateApp is a simple method to notify users that a new version of your iOS app is available!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 96.7%
  • Ruby 3.3%