PSUpdateApp 2.0.5

PSUpdateApp 2.0.5

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released上次发布2014年12月

Daniele Bogo 维护。



  • 作者:
  • Daniele Bogo

PSUpdateApp 第 2.0 版本已上市!!!

新版本 2.0 依赖于 AFNetworking 框架 2.0. AFNetworking 2.0 正式支持 iOS 6+、Mac OS X 10.8+ 以及 Xcode 5。

如果您希望在目标 SDK 为 iOS 5 或 Mac OS X 10.7 的项目中使用 PSUpdateApp,请使用最新的标记 1.x 发行版.

一个简单的方法来通知用户您的 iOS 应用程序有一个新版本可用。

关于

PSUpdateApp 会通知您,如果您的 iOS 应用程序在 AppStore 或其他地方有新的版本。
如果有新版本可用,PSUpdateApp 会显示一个 UIAlertView,通知您有新版本,并给您选择更新应用程序的选项。
此组件依赖于 AFNetworking 框架,使用 AFJSONRequestOperation 方法来读取和解析 JSON 响应。

入门指南

安装

安装 PSUpdateApp 的推荐方法是使用 CocoaPods 软件包管理器,因为它提供了灵活的依赖关系管理,并具有简单直接的安装过程。为了获得最佳结果,建议使用 CocoaPods >= 0.16.0,并通过 Homebrew 安装 Git >= 1.8.0

通过下载

下载 PSUpdateApp 或使用 示例项目。打开 PSUpdateApp.xcworkspace(CocoaPods 需要)。

集成

PSUpdateApp 具有简单的集成

  • PSUpdateApp.h 导入到您应用程序的 AppDelegate 或预编译头文件 (.pch)
  • 在 AppDelegate.m 中的 application:didFinishLaunchingWithOptions: 方法定义您的 PSUpdateApp 对象。
- (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 manager] startWithAppID:@"454638411"];

//--- 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 manager] startWithAppID:@"454638411" 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 manager] 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 manager] 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 manager] setDaysUntilPrompt:10];

//--- ALERT TEXT
//    You can set a custom title and/or a custom message for the PSUpdateApp alert
//    [[PSUpdateApp manager] setAlertTitle:@"Custom Title"];
//    [[PSUpdateApp manager] setAlertDefaultMessage:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit."];

//    3 different properties for the message:
//    alertDefaultMessage   -> default mode
//    alertForceMessage     -> force the update. The alert has only the update button
//    alertRemindMessage    -> Add the remind me button.

    return YES;
}
  • 在 AppDelegate.m 中的 applicationDidBecomeActive: 方法中启动检测可用应用程序版本。
- (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 manager] detectAppVersion:nil];

//--- DETECT VERSION WITH BLOCK
//    You can use the completion block to implement you custom alert and actions
//    [[PSUpdateApp manager] detectAppVersion:^(NSError *error, BOOL success) {
//        NSLog(@"UPDATE");
//    }];
}

自定义URL

如果您想在临时分发中使用PSUpdateApp,或在企业应用中使用,可以通过使用以下结构的JSON调用startWithRoute:来启动PSUpdateApp。

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

如果您想在自定义URL和PSUpdateApp的appStoreLocation属性之间创建一个stringWithFormat:,请使用setURLAdHoc:

注意

  • 此项目需要ARC和iOS针对6.0的版本
  • 使用PSUpdateApp属性来更改PSUpdateApp的默认值:例如应用程序名称或商店位置
  • 它已本地化
  • 示例项目中包含一个简单的BDD测试
  • 在自定义JSON结构中,有一个新的字段叫做"type",用于设置从远程(默认策略或强制策略)的PSUpdateStrategy。

本地化

  • 英语
  • 意大利语
  • 西班牙语
  • 阿拉伯语
  • 韩语
  • 中文
  • 俄语

版本

2.0.5

创建者

Daniele Bogo

鸣谢

许可证

MIT许可证(MIT)版权所有(c)2014 Paper Street Soap Design

特此免费授予任何获得此软件及其相关文档文件(以下简称“软件”)副本的个人Occur in the Free ap to deal in the Software without restriction,包括但不限于使用、复制、修改、合并、发布、分发、许可和/或出售软件副本,并允许拥有软件的个人执行此类操作,但受以下条件约束

上述版权声明和许可声明应包含在软件的任何副本或实质部分的副本中。

软件按“原样”提供,不提供任何明确或暗示的保证,包括但不限于适销性、适用于特定目的和无侵犯性的担保。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论该责任是基于合同、侵权或其他原因,不论该责任出自、涉及或与软件或其使用(或其它行为)有关。