gpt4 book ai didi

ios - 在运行时获取配置文件的到期日期?

转载 作者:可可西里 更新时间:2023-11-01 03:09:02 25 4
gpt4 key购买 nike

我有一个应用程序,我经常通过临时分发方法将其分发给测试人员。这些测试人员中的一些人“随时待命”并且对配置文件和季度到期有足够的了解,并且可以(如果我忘记了)插入我重建一个新版本供他们测试。

然而,一些用户似乎总是到了它停止运行的地步,然后提示和提示它——尽管他们可能不理会 iOS 级别的提醒。

我的问题是,我能否以编程方式在运行时获取到期日期并执行我自己的“应用内”警报或系统通知以提醒他们下载更新版本?

最佳答案

你正在寻找类似的东西

"<key>ExpirationDate</key><date>2014-12-06T00:26:10Z</date>" in [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]

但要做到这一点并不容易!此代码可以改进,部分代码基于其他 stackoverflow 帖子。注意:另一种选择是加载项目 plist 之间的所有内容和/plist 到...一个 plist(字典)。但是因为我们已经在那里了,所以我们只是手动找到 sibling 。

- (NSString*) getExpiry{

NSString *profilePath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
// Check provisioning profile existence
if (profilePath)
{
// Get hex representation
NSData *profileData = [NSData dataWithContentsOfFile:profilePath];
NSString *profileString = [NSString stringWithFormat:@"%@", profileData];

// Remove brackets at beginning and end
profileString = [profileString stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@""];
profileString = [profileString stringByReplacingCharactersInRange:NSMakeRange(profileString.length - 1, 1) withString:@""];

// Remove spaces
profileString = [profileString stringByReplacingOccurrencesOfString:@" " withString:@""];


// Convert hex values to readable characters
NSMutableString *profileText = [NSMutableString new];
for (int i = 0; i < profileString.length; i += 2)
{
NSString *hexChar = [profileString substringWithRange:NSMakeRange(i, 2)];
int value = 0;
sscanf([hexChar cStringUsingEncoding:NSASCIIStringEncoding], "%x", &value);
[profileText appendFormat:@"%c", (char)value];
}

// Remove whitespaces and new lines characters
NSArray *profileWords = [profileText componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

//There must be a better word to search through this as a structure! Need 'date' sibling to <key>ExpirationDate</key>, or use regex
BOOL sibling = false;
for (NSString* word in profileWords){
if ([word isEqualToString:@"<key>ExpirationDate</key>"]){
NSLog(@"Got to the key, now need the date!");
sibling = true;
}
if (sibling && ([word rangeOfString:@"<date>"].location != NSNotFound)) {
NSLog(@"Found it, you win!");
NSLog(@"Expires: %@",word);
return word;
}
}

}

return @"";
}

关于ios - 在运行时获取配置文件的到期日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18961267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com