在运行时获取供应configuration文件的到期date?

我有一个应用程序,我经常通过临时分发方法传递给testing人员。 这些testing人员中的一些人对“configuration文件”和季度到期有足够的了解,并且可以(如果我忘记了)给我一个小小的build议,重新构build一个新的版本供他们testing。

然而,有些用户似乎总是停止运行,然后喋喋不休,尽pipe他们可能会解雇iOS级别的提醒。

我的问题是我可以编程方式在运行时获取失效date,并做我自己的“应用程序内”警报或系统通知,提醒他们拉下新版本?

你正在寻找类似的东西

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

但到那里并不容易! 这段代码可以改进,其中的一部分是基于其他stackoverflow的职位。 注意:另一个select是将plist和plist之间的所有内容加载到plist(字典)中。 但是既然我们已经在那里了,我们就亲自find兄弟姐妹。

 - (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 @""; } 
Interesting Posts