iOS Enterprise App Distribution – Provisioning Profile 已过期
iOS Enterprise App Distribution – Provisioning Profile expired
我如何在配置文件过期时签入应用程序并通知用户有关日期?
我在这里找到了。但是这个文件不包含在项目的包中。也许有一些选择?谢谢
尽管这是一个 MAC OS X prov 检查器,它同样适用于 iOS:
https://github.com/LigeiaRowena/ProvisioningInfo
就个人而言,该信息不应打扰您的用户。您应该清楚地记录它们何时过期,并通过推送通知 and/or 某种形式的 REST api 通知用户过期日期。
理想情况下,处理此问题的最佳方法是定期(至少每年一次)推出仅包含新的嵌入式 mprov 的更新。
您是否特别需要您的用户通知您您的配置文件何时到期?
但是在读取plist文件方面:
[NSDictionary dictionaryWithContentsOfFile:@"path/to/file.plist"]
这似乎也是之前回答过的问题:
Get the EXPIRATION date of a Provisioning Profile at Run-time?
但要重申代码:
- (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 @"";
}
我如何在配置文件过期时签入应用程序并通知用户有关日期?
我在这里找到了。但是这个文件不包含在项目的包中。也许有一些选择?谢谢
尽管这是一个 MAC OS X prov 检查器,它同样适用于 iOS:
https://github.com/LigeiaRowena/ProvisioningInfo
就个人而言,该信息不应打扰您的用户。您应该清楚地记录它们何时过期,并通过推送通知 and/or 某种形式的 REST api 通知用户过期日期。
理想情况下,处理此问题的最佳方法是定期(至少每年一次)推出仅包含新的嵌入式 mprov 的更新。
您是否特别需要您的用户通知您您的配置文件何时到期?
但是在读取plist文件方面:
[NSDictionary dictionaryWithContentsOfFile:@"path/to/file.plist"]
这似乎也是之前回答过的问题:
Get the EXPIRATION date of a Provisioning Profile at Run-time?
但要重申代码:
- (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 @"";
}