Created
March 17, 2020 10:44
-
-
Save alectogeek/259ec7b15a54470ec70e6eec7fcd96bb to your computer and use it in GitHub Desktop.
Revisions
-
alectogeek created this gist
Mar 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ FIRRemoteConfig *remoteConfig = [FIRRemoteConfig remoteConfig]; long expiration = (long)call.arguments[@"expiration"]; [remoteConfig fetchWithExpirationDuration:expiration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { NSNumber *lastFetchTime = [[NSNumber alloc] initWithLong:(long)[[remoteConfig lastFetchTime] timeIntervalSince1970] * 1000]; NSString *lastFetchStatus = [self mapLastFetchStatus:(FIRRemoteConfigFetchStatus)[remoteConfig lastFetchStatus]]; NSMutableDictionary *resultDict = [[NSMutableDictionary alloc] init]; resultDict[@"lastFetchTime"] = lastFetchTime; resultDict[@"lastFetchStatus"] = lastFetchStatus; if (status != FIRRemoteConfigFetchStatusSuccess) { FlutterError *flutterError; if (status == FIRRemoteConfigFetchStatusThrottled) { int mills = [[error.userInfo valueForKey:FIRRemoteConfigThrottledEndTimeInSecondsKey] intValue] * 1000; resultDict[@"fetchThrottledEnd"] = [[NSNumber alloc] initWithInt:mills]; NSString *errorMessage = @"Fetch has been throttled. See the error's fetchThrottledEnd " "field for throttle end time."; flutterError = [FlutterError errorWithCode:@"fetchFailedThrottled" message:errorMessage details:resultDict]; } else { NSString *errorMessage = @"Unable to complete fetch. Reason is unknown " "but this could be due to lack of connectivity."; flutterError = [FlutterError errorWithCode:@"fetchFailed" message:errorMessage details:resultDict]; } result(flutterError); } else { result(resultDict); } }];