Giter Site home page Giter Site logo

williamren / psupdateapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielebogo/psupdateapp

0.0 2.0 0.0 220 KB

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

Home Page: https://github.com/danielebogo/PSUpdateApp

License: MIT License

psupdateapp's Introduction

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.8'

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.8",
      "trackViewUrl": "http://paperstreetsoapdesign.com/development/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
  • Chinese
  • Russian

Version

1.0.8

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.

psupdateapp's People

Contributors

danielebogo avatar mixdesign avatar seanmoon avatar

Watchers

william avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.