AndVersion 1.2.2

AndVersion 1.2.2

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

Kadir Kemal Dursun维护。




  • kadirkemal

AndVersion

CI Status Version License Platform

此库通过使用提供的json文件url检查Apple Store上的更新。如果希望的话,当有新版本可用时,库还可以向用户列出新增信息。

屏幕截图

示例JSON文件

{
    "AndVersion": {
    "CurrentVersion": "1.8.3",
    "MinVersion": "1.2.5",
    "AppStoreId": "1088280260",
    "WhatsNew": {
        "en": [
            "3D home tours (where offered by rental listing).",
            "Minor enhancements to Schools information shown for a property",
            "Bug fixes and performance improvements"
        ],
        "tr": [
            "3D konut turu (danışman tarafından eklenmişse).",
            "Bir emlak etrafında gösterilen okul bilgileri için iyileştirmeler",
            "Hata düzeltmeleri ve performans iyileştirmeleri"
        ]
    }
    }
}

所有字段都是必填项。如果json文件中缺失其中之一,AndVersion-iOS将不会控制版本。

CurrentVersion:Apple Store上的版本号。

MinVersion:希望支持的最高版本号。

AppStoreId:当前应用程序的商店ID。

WhatsNew:在CurrentVersion中添加的新特性的列表。内部对象的键应该是区域语言代码,内部对象的价值应该是字符串数组

安装

AndVersion 可通过 CocoaPods 获取。要安装它,只需在 Podfile 中添加以下行

pod 'AndVersion'

用法

您可以使用 AndVersion 的三种方式。

使用代理

选择此选项时,AndVersion 会通知当前状况,这应由开发者(如果需要)来处理。将以下代码添加到您的 AppDelagate.m 文件中的 didFinishLaunchingWithOptions 中

#import "AndVersion.h"

@interface zngAppDelegate() <AndVersionDelegate>
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [AndVersion sharedAndVersion].delegate = self;
    [[AndVersion sharedAndVersion] checkVersionWithUrl:@"https://andversion.com/sample/demoIOS.json"];
    
    // Override point for customization after application launch.
    return YES;
}

AndVersionDelegate 中的所有方法都是可选的。您只需实现需要的那些即可。

-(void) didAndVersionFindNoUpdate{
    NSLog(@"No New Version");
}

-(void) didAndVersionFindOptionalUpdate:(NSArray <NSString *> *) whatsNew{
    NSLog(@"Optional New Version");
    for(NSString *wNew in whatsNew){
        NSLog(@"%@", wNew);
    }
}

-(void) didAndVersionFindMandatoryUpdate:(NSArray <NSString *> *) whatsNew{
    NSLog(@"Mandatory New Version");
    for(NSString *wNew in whatsNew){
        NSLog(@"%@", wNew);
    }
}

-(void) didAndVersionMeetNewVersion:(NSArray <NSString *> *) whatsNew{
    NSLog(@"Meet New Version");
    for(NSString *wNew in whatsNew){
        NSLog(@"%@", wNew);
    }
}

使用自动驾驶

选择此选项时,AndVersion 控制 json 文件中的参数并处理想要的情况。将以下代码添加到您的 AppDelagate.m 文件中的 didFinishLaunchingWithOptions 中

#import "AndVersion.h"

#import "AndVersion.h"


```objective c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //if showAlertForNewVersion is set true, AndVersion shows whats new info view when the user must update his app.
    //The user can not use the app without updating
    [AndVersion sharedAndVersion].showAlertForMandatoryUpdate = YES;
    
    //if showAlertForOptionalUpdate is set true, AndVersion shows whats new info view when the app version is old but ok.
    //The user can use the app without updating
    [AndVersion sharedAndVersion].showAlertForOptionalUpdate = YES;
    
    //if showAlertForNewVersion is set true, AndVersion shows whats new info view when the user updates his app.
    [AndVersion sharedAndVersion].showAlertForNewVersion = YES;
    
    [[AndVersion sharedAndVersion] checkVersionWithUrl:@"https://andversion.com/sample/demoIOS.json"];
    
    // Override point for customization after application launch.
    return YES;
}

使用回调和自动驾驶

通过实现两者,您可以使用回调和自动驾驶功能。

参数

这些参数仅用于自动驾驶模式。所有这些参数都具有默认值。

[AndVersion sharedAndVersion].configuration.infoViewBacgroundColor = [UIColor blueColor];
//Default value is [UIColor blackColor]

[AndVersion sharedAndVersion].configuration.infoViewBacgroundAlpha = 0.5;
//Default value is 0.85

[AndVersion sharedAndVersion].configuration.infoViewTableSeperatorColor = [UIColor greenColor];
//Default value is "89c400"
[AndVersion sharedAndVersion].configuration.infoViewTitleColor = [UIColor redColor];
//Default value is [UIColor blackColor]

[AndVersion sharedAndVersion].configuration.infoinfoViewTitleFont = [UIFont fontWithName:@"FontName" size:16];
//Default value is [UIFont fontWithName:@"Verdana" size:14]

[AndVersion sharedAndVersion].configuration.infoViewTitleForNeedUpdate = @"Update your app for these awesome features";
//Default value is "It is recommended to update your applciation"

[AndVersion sharedAndVersion].configuration.infoViewTitleForNewVersion = @"Thanks for updating";
//Default value is "New features in this version"
[AndVersion sharedAndVersion].configuration.infoViewButtonFont = [UIFont fontWithName:@"FontName" size:14];
//Default value is [UIFont fontWithName:@"Verdana" size:14]

[AndVersion sharedAndVersion].configuration.infoViewButtonRadius = 4;
//Default value is -1, It means "make the button rounded"
[AndVersion sharedAndVersion].configuration.infoViewOKButtonColor = [UIColor redColor];
//Default value is "89c400"

[AndVersion sharedAndVersion].configuration.infoViewOKButtonTextColor = [UIColor blackColor];
//Default value is [UIColor whiteColor]

[AndVersion sharedAndVersion].configuration.infoViewOKButtonTitle = @"OK";
//Default value is "Okay"
[AndVersion sharedAndVersion].configuration.infoViewContinueButtonColor = [UIColor redColor];
//Default value is "d80e2b"

[AndVersion sharedAndVersion].configuration.infoViewUpdateButtonTextColor = [UIColor blackColor];
//Default value is [UIColor whiteColor]

[AndVersion sharedAndVersion].configuration.infoViewContinueButtonTitle = @"GO";
//Default value is "Continue"
[AndVersion sharedAndVersion].configuration.infoViewUpdateButtonColor = [UIColor redColor];
//Default value is "89c400"

[AndVersion sharedAndVersion].configuration.infoViewUpdateButtonTextColor = [UIColor blackColor];
//Default value is [UIColor whiteColor]

[AndVersion sharedAndVersion].configuration.infoViewUpdateButtonTitle = @"UPDATE";
//Default value is "Update"
[AndVersion sharedAndVersion].configuration.infoViewWhatsNewTextColor = [UIColor blackColor];
//Default value is [UIColor whiteColor]

[AndVersion sharedAndVersion].configuration.infoViewWhatsNewFont = [UIFont fontWithName:@"FontName" size:10];
//Default value is [UIFont fontWithName:@"Verdana" size:12]

作者

Zingat 移动团队

许可协议

AndVersion 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。