2013-09-23 10 views
5

मेरे पास एक ऐप है जो मैं नियमित रूप से विज्ञापन-प्रसार वितरण विधि के माध्यम से परीक्षकों को पास करता हूं। इनमें से कुछ परीक्षक 'गेंद पर' हैं और प्रावधान प्रोफाइल और त्रैमासिक समाप्ति के बारे में पर्याप्त जानते हैं और (अगर मैं भूल जाता हूं) मुझे परीक्षण के लिए एक नया संस्करण पुनर्निर्माण करने के लिए एक झुकाव देता है।रन-टाइम पर प्रोविजनिंग प्रोफाइल की समाप्ति तिथि प्राप्त करें?

हालांकि कुछ उपयोगकर्ता हमेशा उस बिंदु तक पहुंचते हैं जहां यह दौड़ना बंद कर देता है और फिर इसके बारे में कुचलना और चिल्लाता है - शायद उन्हें आईओएस स्तर अनुस्मारक को खारिज करने के बावजूद।

मेरा प्रश्न है क्या मैं प्रोग्रामटाइम रनटाइम पर समाप्ति तिथि को पकड़ सकता हूं और अपना खुद का 'इन-ऐप' अलर्ट या सिस्टम नोटिफिकेशन कर सकता हूं ताकि उन्हें नए संस्करण को खींचने के लिए याद दिलाया जा सके?

उत्तर

6

आप

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

की तरह कुछ के लिए देख रहे हैं लेकिन हो रही वहाँ आसान नहीं है! इस कोड में सुधार किया जा सकता है, इसके कुछ हिस्सों अन्य stackoverflow पदों पर आधारित थे। नोट: एक और विकल्प आइटम प्लिस्ट और/plist ... के बीच सबकुछ लोड करना होगा ... एक प्लेस्ट (शब्दकोश)। लेकिन चूंकि हम पहले से ही वहां हैं, हम सिर्फ हाथ से भाई पा रहे हैं।

- (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 @""; 
} 
+0

प्रोफाइल के लिए इसकी वापसी शून्य पहली पंक्ति पर ही है। मैं xcode 8.2.1 का उपयोग कर रहा हूं और इस उद्देश्य-सी कोड का उपयोग तेजी से कर रहा हूं। – Skywalker

+0

क्या आप सिम्युलेटर में कोड चला रहे हैं? यह हस्ताक्षरित नहीं है, इसलिए सिम्युलेटर पर चलने पर कोई एम्बेडेड.मोबाइलप्रोविजन फ़ाइल नहीं होगी। भौतिक डिवाइस पर कोड चलाने का प्रयास करें (कोड पर हस्ताक्षर किए जाने चाहिए और एम्बेडेड.मोबाइलप्रोविजन फ़ाइल को सिद्धांत रूप में वहां होना चाहिए। – wottle

संबंधित मुद्दे