2016-10-18 76 views
0

我無法從Firebase RemoteConfig獲取信息。在應用程序安裝中,我在MainController視圖控制器之前有一個語言選擇屏幕。在MainController視圖控制器上,我正在執行RemoteConfig提取。當語言選擇屏幕顯示在MainController視圖控制器之前時,它首次運行。但是,從下一次,它崩潰上這一行:Firebase遠程配置崩潰(目標c iOS)

[self.remoteConfig fetchWithExpirationDuration:expirationDuration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { 

但下列情況除外:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString firstObject]: unrecognized selector sent to instance 0xa0000000000616a2' 
*** First throw call stack: 
(
    0 CoreFoundation      0x000000010d20134b __exceptionPreprocess + 171 
    1 libobjc.A.dylib      0x000000010cc6221e objc_exception_throw + 48 
    2 CoreFoundation      0x000000010d270f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 
    3 CoreFoundation      0x000000010d186c15 ___forwarding___ + 1013 
    4 CoreFoundation      0x000000010d186798 _CF_forwarding_prep_0 + 120 
    5 English        0x0000000107f44e1b -[GIPLocale googleLanguageWithAppleLanguages:] + 33 
    6 English        0x0000000107f45396 -[GIPLocale recalculateLocale] + 54 
    7 English        0x0000000107f44c26 -[GIPLocale initWithLanguageMappings:] + 99 
    8 English        0x0000000107f44b77 __25+[GIPLocale googleLocale]_block_invoke + 41 
    9 libdispatch.dylib     0x000000010da900cd _dispatch_client_callout + 8 
    10 libdispatch.dylib     0x000000010da751fc dispatch_once_f + 501 
    11 English        0x0000000107f44b4c +[GIPLocale googleLocale] + 42 
    12 English        0x0000000107f42d06 +[RCNDevice deviceLocale] + 31 
    13 English        0x0000000107f43344 +[RCNDevice hasDeviceContextChanged:projectIdentifier:] + 325 
    14 English        0x0000000107f3e133 -[RCNConfigFetch fetchAllConfigsWithExpirationDuration:completionHandler:] + 150 
    15 English        0x0000000107f3577f -[FIRRemoteConfig fetchWithExpirationDuration:completionHandler:] + 77 

UPDATE:,如果我表現出的語言選擇屏幕不要緊,或不。它始終在全新安裝上運行,並在下次啓動時停止工作。

這是我正在使用的完整代碼。

-(void)viewDidAppear:(BOOL)animated{ 
    //Display select language settings 
    if (![[NSUserDefaults standardUserDefaults] boolForKey:DISPLAY_LANGUAGE_SETTING]) 
    { 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
     [defaults setBool:TRUE forKey:DISPLAY_LANGUAGE_SETTING]; 
     [defaults synchronize]; 
     //Display Language Screen 
     AGSelectLanguageViewController *languageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"AGSelectLanguageViewController"]; 
     self.modalPresentationStyle = UIModalPresentationFullScreen; 
     [self presentViewController:languageViewController animated:NO completion:nil]; 
    } 

    [self configFireBase]; 

} 
    -(void)configFireBase{ 
     // Firebase Configuration 
     self.remoteConfig = [FIRRemoteConfig remoteConfig]; 
     //Enabling development mode 
     FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; 
     self.remoteConfig.configSettings = remoteConfigSettings; 

     //Set default Remote Config values 
     [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"]; 

     [self fetchConfig]; 
    } 

- (void)fetchConfig { 
    _discount_percentage = self.remoteConfig[DISCOUNT_PERCENTAGE].numberValue.floatValue; 

    long expirationDuration = 3600; 

    if (self.remoteConfig.configSettings.isDeveloperModeEnabled) { 
     expirationDuration = 0; 
    } 


    [self.remoteConfig fetchWithExpirationDuration:expirationDuration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { 
     if (status == FIRRemoteConfigFetchStatusSuccess) { 
      NSLog(@"Config fetched!"); 
      [self.remoteConfig activateFetched]; 
     } else { 
      NSLog(@"Config not fetched"); 
      NSLog(@"Error %@", error.localizedDescription); 
     } 
    }]; 
} 

我在哪裏錯了?請幫忙。

回答

2

的GIPLocale類做谷歌和蘋果的名稱爲不同語言環境之間的一些映射,併爲它拉應用程序的語言環境從NSUserDefaults的一部分:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
NSArray *languages = [defaults objectForKey:@"AppleLanguages"]; 

我猜測,那地方違約項越來越設爲只是一個字符串或類似的,而不是一個數組 - 檢查你是否在你的應用程序的任何地方引用該字符串。

+0

非常感謝:)我在AppleLanguages中插入了這個值 - [defaults setObject:[localeList objectForKey:languageChoosen] forKey:@「AppleLanguages」];這造成了一切麻煩。 – Pria