iOS企业应用程序分发 - 供应配置文件已过期

时间:2015-06-10 14:08:09

标签: ios date provisioning-profile

如何在过期配置文件时检入应用程序并通知用户有关日期的信息?

Example

我在这里找到了。但是这个文件不包含在项目包中。也许有一些选择?感谢

1 个答案:

答案 0 :(得分:1)

尽管这是一个MAC OS X prov检查器,但它也适用于iOS:

https://github.com/LigeiaRowena/ProvisioningInfo

就个人而言,该信息不应该打扰您的用户。您应该有一个明确的过期时间记录,并通过推送通知和/或某种形式的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 @"";
}