firebase / firebase/firebase-ios-sdk

[FR]: FIROptions init with NSData

Open
#11,190 3 comments 1 reaction 0 assignees View on GitHub
api: analytics api: core type: feature request
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description

1. We would like to get rid of storing **GoogleService-Info.plist** in the bundle that is required for Firebase configuration.
2. There is no way to init `FIROptions` using a **content** of the **GoogleService-Info.plist**.
2.1. `-initWithGoogleAppID:GCMSenderID:` is not valid due to [**this**](https://github.com/firebase/firebase-ios-sdk/discussions/8603#discussioncomment-1269159).
2.2. `-initWithContentsOfFile:` requires to store **GoogleService-Info.plist** in the bundle.
3. Better to have an initializer of `FIROptions` with `NSData` from **GoogleService-Info.plist**.

This feature should be useful for [**those**](https://github.com/firebase/firebase-ios-sdk/issues/1442 ) who would like to keep the **GoogleService-Info.plist** data in a more secure way than storing files in the bundle.

### API Proposal

Here are snippets to show how it should work.

**FIROptions.h**
```objc
- (nullable instancetype)initWithData:(NSData *)data NS_DESIGNATED_INITIALIZER;
```

**FIROptions.m**
```objc
- (instancetype)initWithData:(NSData *)data {
self = [super init];
if (self) {
if (data == nil) {
FIRLogError(kFIRLoggerCore, @"I-COR000013", @"The plist file data is nil.");
return nil;
}
id optionsDictionary = [NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable
format:NULL
error:NULL];
if (optionsDictionary == nil || ![optionsDictionary isKindOfClass:[NSDictionary class]]) {
FIRLogError(kFIRLoggerCore, @"I-COR000014", @"The configuration data is corrupted.");
return nil;
}
_optionsDictionary = [optionsDictionary mutableCopy];
}
return self;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.