Skip to content

[FR]: FIROptions init with NSData #11190

Open
@unboxme

Description

@unboxme

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.
    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 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

- (nullable instancetype)initWithData:(NSData *)data NS_DESIGNATED_INITIALIZER;

FIROptions.m

- (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;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions