Harpy 4.1.14

Harpy 4.1.14

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布2018年6月

Arthur Ariel Sabintsev 维护。



Harpy 4.1.14

  • Arthur Ariel Sabintsev

Harpy

当你的应用程序有新版本可用时通知用户,并提示他们升级。

Build Status

CocoaPods Carthage Compatible CocoaPods CocoaPods

关于

Harpy 会检查用户当前安装的你的 iOS 应用版本与 App Store 中当前可用的版本是否一致。如果有新版本,可以向用户展示一个弹窗通知他们新版本的信息,并为他们提供更新应用程序的选项。

Harpy 是基于 语义版本控制 系统构建的。

  • 语义版本控制是一个由三个数字组成的版本控制系统(例如,1.0.0)
  • Harpy 还支持由两个数字组成的版本(例如,1.0)
  • Harpy 还支持由四个数字组成的版本(例如,1.0.0.0)
  • Harpy 只支持数字。

Swift 支持

Harpy 由我自己和 Aaron Brager 端口移植到 Swift。我们将新项目命名为 Siren

功能

  • CocoaPods 支持
  • Carthage 支持
  • 支持40多种语言本地化(见 本地化
  • 更新前设备兼容性检查(见 设备兼容性
  • 三种类型的通知(见 截图和通知类型
  • 可选的代理方法(见 可选代理 部分)
  • 单元测试!

截图

  • 左侧图片 强制用户更新应用程序。
  • 中间图片 给用户更新应用程序的选项。
  • 右侧图片 给用户跳过当前更新的选项。
  • 这些选项由位于 Harpy.h 中的 HarpyAlertType 枚举控制的。

安装说明

CocoaPods

pod 'Harpy'

Carthage

github "ArtSabintsev/Harpy"

用户手册

将“Harpy”文件夹复制到您的Xcode项目中。它包含Harpy.h和Harpy.m文件。

设置

  1. Harpy.h 导入您的AppDelegate或预编译头文件(.pch)中。
  2. 在您的 AppDelegate 中,可以选择设置 alertType
  3. 在您的 AppDelegate 中,调用 一种checkVersion 方法,因为所有三种方法都在应用程序首次启动时执行检查。使用以下任意一种:
    • application:didFinishLaunchingWithOptions: 中的 checkVersion
    • applicationDidBecomeActive: 中的 checkVersionDaily
    • applicationDidBecomeActive: 中的 checkVersionWeekly
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

	// Present Window before calling Harpy
	[self.window makeKeyAndVisible];

	// Set the UIViewController that will present an instance of UIAlertController
	[[Harpy sharedInstance] setPresentingViewController:_window.rootViewController];

    // (Optional) Set the Delegate to track what a user clicked on, or to use a custom UI to present your message.
        [[Harpy sharedInstance] setDelegate:self];

    // (Optional) When this is set, the alert will only show up if the current version has already been released for X days.
    // By default, this value is set to 1 (day) to avoid an issue where Apple updates the JSON faster than the app binary propogates to the App Store.
        [[Harpy sharedInstance] setShowAlertAfterCurrentVersionHasBeenReleasedForDays:3];

	// (Optional) The tintColor for the alertController
	[[Harpy sharedInstance] setAlertControllerTintColor:@"<#alert_controller_tint_color#>"];

	// (Optional) Set the App Name for your app
	[[Harpy sharedInstance] setAppName:@"<#app_name#>"];

	/* (Optional) Set the Alert Type for your app
	 By default, Harpy is configured to use HarpyAlertTypeOption */
	[[Harpy sharedInstance] setAlertType:<#alert_type#>];

	/* (Optional) If your application is not available in the U.S. App Store, you must specify the two-letter
	 country code for the region in which your applicaiton is available. */
	[[Harpy sharedInstance] setCountryCode:@"<#country_code#>"];

	/* (Optional) Overrides system language to predefined language.
	 Please use the HarpyLanguage constants defined in Harpy.h. */
	[[Harpy sharedInstance] setForceLanguageLocalization:<#HarpyLanguageConstant#>];

        /* (Optional): Delays the update prompt by a specific number of days. By default,
	this value is set to 1 day to avoid an issue where Apple updates the JSON faster than the app binary propogates to the App Store.*/
        [[Harpy sharedInstance] setShowAlertAfterCurrentVersionHasBeenReleasedForDays:<#Int#>];

	// Perform check for new version of your app
	[[Harpy sharedInstance] checkVersion];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {

	/*
	 Perform daily check for new version of your app
	 Useful if user returns to you app from background after extended period of time
 	 Place in applicationDidBecomeActive:

 	 Also, performs version check on first launch.
 	*/
	[[Harpy sharedInstance] checkVersionDaily];

	/*
	 Perform weekly check for new version of your app
	 Useful if you user returns to your app from background after extended period of time
	 Place in applicationDidBecomeActive:

	 Also, performs version check on first launch.
	 */
	[[Harpy sharedInstance] checkVersionWeekly];

}

- (void)applicationWillEnterForeground:(UIApplication *)application {
	/*
	 Perform check for new version of your app
	 Useful if user returns to you app from background after being sent tot he App Store,
	 but doesn't update their app before coming back to your app.

 	 ONLY USE THIS IF YOU ARE USING *HarpyAlertTypeForce*

 	 Also, performs version check on first launch.
 	*/
	[[Harpy sharedInstance] checkVersion];
}

配置完成!

针对补丁、次要和主要更新提供区分报警

如果您希望为修订、补丁、次要和/或主要更新设置不同类型的报警,只需在调用任何 checkVersion 方法之前添加以下一条或多条 可选 代码即可:

	/* By default, Harpy is configured to use HarpyAlertTypeOption for all version updates */
	[[Harpy sharedInstance] setPatchUpdateAlertType:<#alert_type#>];
	[[Harpy sharedInstance] setMinorUpdateAlertType:<#alert_type#>];
	[[Harpy sharedInstance] setMajorUpdateAlertType:<#alert_type#>];
	[[Harpy sharedInstance] setRevisionUpdateAlertType:<#alert_type#>];

可选的代理和代理方法

如果您想处理或跟踪最终用户的行为,已经为您提供了四种代理方法。

	// User presented with update dialog
	- (void)harpyDidShowUpdateDialog;

	// User did click on button that launched App Store.app
	- (void)harpyUserDidLaunchAppStore;

	// User did click on button that skips version update
	- (void)harpyUserDidSkipVersion;

	// User did click on button that cancels update dialog
	- (void)harpyUserDidCancel;

如果您想使用自己的UI,请使用以下代理方法获取如果有可用新建版本时本地化更新消息

- (void)harpyDidDetectNewVersionWithoutAlert:(NSString *)message;

本地化

Harpy支持以下语言本地化:

  • 阿拉伯语
  • 亚美尼亚语
  • 巴斯克语
  • 中文(简体和繁体)
  • 克罗地亚语
  • 捷克语
  • 丹麦语
  • 荷兰语
  • 英语
  • 爱沙尼亚语
  • 芬兰语
  • 法语
  • 德语
  • 希腊语
  • 希伯来语
  • 匈牙利语
  • 印度尼西亚语
  • 意大利语
  • 日语
  • 韩语
  • 拉脱维亚语
  • 立陶宛语
  • 马来语
  • 挪威语(Bokmål)
  • 波斯语(伊朗,阿富汗,波斯语)
  • 波兰语
  • 葡萄牙语(巴西和葡萄牙)
  • 俄语
  • 塞尔维亚语(西里尔文和拉丁文)
  • 斯洛文尼亚语
  • 西班牙语
  • 瑞典语
  • 泰语
  • 土耳其语
  • 乌克兰语
  • 乌尔都语
  • 越南语

您可能希望更新对话框始终以某种语言显示,忽略iOS的语言设置(例如,特定国家发布的应用程序)。

您可以通过这种方式启用它

[[Harpy sharedInstance] setForceLanguageLocalization<#HarpyLanguageConstant#>];

设备兼容性

如果有应用程序更新可用,Harpy会检查用户的设备上安装的iOS版本是否与应用程序更新所需版本兼容。例如,如果用户在设备上安装了iOS 9,但应用程序更新需要iOS 10,则不会显示警报。这解决了有关应用程序更新的《em>假阳性问题。

测试Harpy

临时更改Xcode(在.xcodeproj内的)版本字符串,使其比目前App Store中可用的版本更旧。然后构建并运行您的应用程序,您应该会看到警报。

如果您目前没有在商店中的应用程序,将您的bundleID更改为商店中已经存在的bundleID。在这个库附带的示例应用程序中,我们使用iTunes Connect Mobile应用程序的bundleID:com.apple.itunesconnect.mobile

关于App Store提交的重要提示

App Store的审核员将不会看到警报。

分期发布

2017年,Apple宣布了逐步推出应用更新的功能(也称为分阶段发布)。Harpy将继续像过去一样工作,向所有用户展示更新模态窗口。如果您为特定版本选择了分阶段发布的选项,您需要在发布完成后远程禁用Harpy。

由以下团队创建和维护的

Arthur Ariel Sabintsev