SRGAppVerWatcher 0.0.2

SRGAppVerWatcher 0.0.2

测试测试版
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年1月

Norihiro Sakamoto维护。



  • Norihiro Sakamoto

SRGAppVerWatcher 可以检测应用的安装或更新,并且您可以通过使用 blocks 在应用安装或更新后只运行一次代码。

安装

将以下行添加到您的 podfile 并运行 pod update

pod 'SRGAppVerWatcher', :git => 'https://github.com/soragoto/SRGAppVerWatcher.git', :tag => '0.0.1'

使用方法

首先,您需要包含头文件。

#import "SRGAppVerWatcher.h"

您可以使用一个运行一次的 block,在应用安装后。

[[SRGAppVerWatcher sharedWatcher] executeOnceAfterInstall:^{
    // This blocks run just one time after install.
    // ( This block DOSE NOT RUN at after update )
    [yourObject introduceAppFeatures];
}];

您可以使用一个运行一次的 block,在应用更新后。

  • Blocks 参数 NSString *from:更新前的应用版号。
  • Blocks 参数 NSString *to:更新后的应用版号。
[[SRGAppVerWatcher sharedWatcher] executeOnceAfterUpdate:^(NSString *from, NSString*to){
    // This blocks run just one time after update.
    // ( This block DOSE NOT RUN at after install )
    [yourObject showWatsNewInUpdate];
    NSLog(@"Update version from:%@ to:%@",from,to);
}];

您可以得到应用安装(或更新)的日期。

NSDate *installDate     = [[SRGAppVerWatcher sharedWatcher] installDate];
NSDate *updateDate      = [[SRGAppVerWatcher sharedWatcher] updateDate];
NSDate *updateDateVer3  = [[SRGAppVerWatcher sharedWatcher] updateDateOf:@"3.0"];

您可以在应用安装时得到版本号。

NSString *installVersion = [[SRGAppVerWatcher sharedWatcher] installVersion];

注意

SRGAppVerWatcher 通过保存当前版号并与之前的版号进行比较来检测更新或安装。因此,您需要在您的应用中从 第一个版本 就开始安装 SRGAppVerWatcher,否则 SRGAppVerWatcher 无法区分更新和安装。