-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Merge FLoC SDK into master branch. #6466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
603119d
Create Segmentation SDK structure for source and unit tests. (#3214)
dmandar cb465a1
Add core support with interop for Segmentation SDK. (#3430)
dmandar 0cf663a
Working drop of Segmentation SDK along with test app and unit tests. …
dmandar 33a0579
update segmetation dependency version
ChaoqunCHEN e6b434c
migrate FloC SDK to depend on FIS SDK directly
ChaoqunCHEN 8e06a28
format floc
ChaoqunCHEN b6eaf23
merge conflict
diwu-arete fabd519
format
ChaoqunCHEN 20f4eb3
Merge branch 'master' of github.com:firebase/firebase-ios-sdk into cc…
diwu-arete bd017c4
using customized FIRapp
ChaoqunCHEN aa530db
merge master
ChaoqunCHEN aa58060
Merge branch 'segmentation-master' into ccq-floc
ChaoqunCHEN f2e331b
remove test plist file
ChaoqunCHEN 9a3b226
Merge branch 'master' into segmentation-master
ChaoqunCHEN a8ab414
Merge branch 'master' into ccq-floc
ChaoqunCHEN 7bd81cf
Merge branch 'segmentation-master' into ccq-floc
ChaoqunCHEN 701c7a1
refactor to capture weakself
ChaoqunCHEN 855f2d4
format
ChaoqunCHEN 564bff2
replace partial mock with class mock
ChaoqunCHEN dc215c7
minor refactoring
ChaoqunCHEN 278132b
use subscript to manipulate dictionary instance
ChaoqunCHEN a824c21
fix import error
ChaoqunCHEN 8c9f5e4
minor refoctoring, addressing comments
ChaoqunCHEN ad3aa80
address comments
ChaoqunCHEN ce13a34
fix configurations
ChaoqunCHEN 516e964
Merge branch 'master' into ccq-floc
ChaoqunCHEN 0a88ac5
format
ChaoqunCHEN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
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 characters
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'FirebaseSegmentation' | ||
s.version = '0.1.0' | ||
s.summary = 'Firebase Segmentation SDK' | ||
s.description = <<-DESC | ||
Firebase Segmentation enables you to associate your custom application instance ID with Firebase for user segmentation. | ||
DESC | ||
|
||
s.homepage = 'https://firebase.google.com' | ||
s.license = { :type => 'Apache', :file => 'LICENSE' } | ||
s.authors = 'Google, Inc.' | ||
s.source = { | ||
:git => 'https://github.com/firebase/firebase-ios-sdk.git', | ||
:tag => 'Segmentation-' + s.version.to_s | ||
} | ||
|
||
s.ios.deployment_target = '8.0' | ||
s.cocoapods_version = '>= 1.4.0' | ||
morganchen12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s.static_framework = true | ||
s.prefix_header_file = false | ||
|
||
s.source_files = [ | ||
'FirebaseSegmentation/Sources/**/*.[mh]', | ||
'FirebaseCore/Sources/Private/*.h', | ||
] | ||
s.public_header_files = 'FirebaseSegmentation/Sources/Public/*.h' | ||
|
||
s.dependency 'FirebaseCore', '~> 6.7' | ||
s.dependency 'FirebaseInstallations', '~> 1.7' | ||
|
||
header_search_paths = { | ||
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"' | ||
} | ||
|
||
s.pod_target_xcconfig = { | ||
'GCC_C_LANGUAGE_STANDARD' => 'c99', | ||
'GCC_PREPROCESSOR_DEFINITIONS' => 'FIRSegmentation_VERSION=' + s.version.to_s | ||
}.merge(header_search_paths) | ||
|
||
s.test_spec 'unit' do |unit_tests| | ||
unit_tests.source_files = 'FirebaseSegmentation/Tests/Unit/*.[mh]' | ||
unit_tests.dependency 'OCMock' | ||
unit_tests.requires_app_host = true | ||
end | ||
end |
Empty file.
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2019 Google | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#import "FirebaseSegmentation/Sources/Public/FIRSegmentation.h" | ||
|
||
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h" | ||
#import "FirebaseCore/Sources/Private/FIRLogger.h" | ||
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h" | ||
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h" | ||
#import "FirebaseSegmentation/Sources/Private/FIRSegmentationComponent.h" | ||
#import "FirebaseSegmentation/Sources/SEGContentManager.h" | ||
|
||
@implementation FIRSegmentation { | ||
NSString *_firebaseAppName; | ||
SEGContentManager *_contentManager; | ||
} | ||
|
||
+ (nonnull FIRSegmentation *)segmentation { | ||
if (![FIRApp isDefaultAppConfigured]) { | ||
[NSException | ||
raise:kFirebaseSegmentationErrorDomain | ||
format:@"FIRApp not configured. Please make sure you have called [FIRApp configure]"]; | ||
} | ||
|
||
return [FIRSegmentation segmentationWithApp:[FIRApp defaultApp]]; | ||
} | ||
|
||
+ (nonnull FIRSegmentation *)segmentationWithApp:(nonnull FIRApp *)firebaseApp { | ||
// Use the provider to generate and return instances of FIRSegmentation for this specific app and | ||
// namespace. This will ensure the app is configured before Remote Config can return an instance. | ||
id<FIRSegmentationProvider> provider = | ||
FIR_COMPONENT(FIRSegmentationProvider, firebaseApp.container); | ||
return [provider segmentation]; | ||
} | ||
|
||
- (void)setCustomInstallationID:(NSString *)customInstallationID | ||
completion:(void (^)(NSError *))completionHandler { | ||
[_contentManager | ||
associateCustomInstallationIdentiferNamed:customInstallationID | ||
firebaseApp:_firebaseAppName | ||
completion:^(BOOL success, NSDictionary *result) { | ||
if (!success) { | ||
// TODO(dmandar) log; pass along internal error code. | ||
NSError *error = [NSError | ||
errorWithDomain:kFirebaseSegmentationErrorDomain | ||
code:FIRSegmentationErrorCodeInternal | ||
userInfo:result]; | ||
completionHandler(error); | ||
} else { | ||
completionHandler(nil); | ||
} | ||
}]; | ||
} | ||
|
||
/// Designated initializer | ||
- (instancetype)initWithAppName:(NSString *)appName FIROptions:(FIROptions *)options { | ||
self = [super init]; | ||
if (self) { | ||
_firebaseAppName = appName; | ||
|
||
// Initialize the content manager. | ||
_contentManager = [SEGContentManager sharedInstanceWithOptions:options]; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
107 changes: 107 additions & 0 deletions
107
FirebaseSegmentation/Sources/FIRSegmentationComponent.m
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright 2019 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "FirebaseSegmentation/Sources/Private/FIRSegmentationComponent.h" | ||
|
||
#import "FirebaseCore/Sources/Private/FIRAppInternal.h" | ||
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h" | ||
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h" | ||
#import "FirebaseSegmentation/Sources/Private/FIRSegmentationInternal.h" | ||
#import "FirebaseSegmentation/Sources/SEGSegmentationConstants.h" | ||
|
||
#ifndef FIRSegmentation_VERSION | ||
#error "FIRSegmentation_VERSION is not defined: \ | ||
add -DFIRSegmentation_VERSION=... to the build invocation" | ||
#endif | ||
|
||
#define STR(x) STR_EXPAND(x) | ||
#define STR_EXPAND(x) #x | ||
|
||
@implementation FIRSegmentationComponent | ||
|
||
/// Default method for retrieving a Segmentation instance, or creating one if it doesn't exist. | ||
- (FIRSegmentation *)segmentation { | ||
// Validate the required information is available. | ||
FIROptions *options = self.app.options; | ||
NSString *errorPropertyName; | ||
if (options.googleAppID.length == 0) { | ||
errorPropertyName = @"googleAppID"; | ||
} else if (options.GCMSenderID.length == 0) { | ||
errorPropertyName = @"GCMSenderID"; | ||
} | ||
|
||
if (errorPropertyName) { | ||
[NSException | ||
raise:kFirebaseSegmentationErrorDomain | ||
format:@"%@", | ||
[NSString | ||
stringWithFormat: | ||
@"Firebase Segmentation is missing the required %@ property from the " | ||
@"configured FirebaseApp and will not be able to function properly. Please " | ||
@"fix this issue to ensure that Firebase is correctly configured.", | ||
errorPropertyName]]; | ||
} | ||
|
||
FIRSegmentation *instance = self.segmentationInstance; | ||
if (!instance) { | ||
instance = [[FIRSegmentation alloc] initWithAppName:self.app.name FIROptions:self.app.options]; | ||
self.segmentationInstance = instance; | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
/// Default initializer. | ||
- (instancetype)initWithApp:(FIRApp *)app { | ||
self = [super init]; | ||
if (self) { | ||
_app = app; | ||
if (!_segmentationInstance) { | ||
_segmentationInstance = [[FIRSegmentation alloc] initWithAppName:app.name | ||
FIROptions:app.options]; | ||
} | ||
} | ||
return self; | ||
} | ||
|
||
#pragma mark - Lifecycle | ||
|
||
+ (void)load { | ||
// Register as an internal library to be part of the initialization process. The name comes from | ||
// go/firebase-sdk-platform-info. | ||
[FIRApp registerInternalLibrary:self | ||
withName:@"fire-seg" | ||
withVersion:[NSString stringWithUTF8String:STR(FIRSegmentation_VERSION)]]; | ||
} | ||
|
||
#pragma mark - Interoperability | ||
|
||
+ (NSArray<FIRComponent *> *)componentsToRegister { | ||
FIRComponent *segProvider = [FIRComponent | ||
componentWithProtocol:@protocol(FIRSegmentationProvider) | ||
instantiationTiming:FIRInstantiationTimingAlwaysEager | ||
dependencies:@[] | ||
creationBlock:^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) { | ||
// Cache the component so instances of Segmentation are cached. | ||
*isCacheable = YES; | ||
return [[FIRSegmentationComponent alloc] initWithApp:container.app]; | ||
}]; | ||
return @[ segProvider ]; | ||
} | ||
|
||
@synthesize instances; | ||
ChaoqunCHEN marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@end |
58 changes: 58 additions & 0 deletions
58
FirebaseSegmentation/Sources/Private/FIRSegmentationComponent.h
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2019 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "FIRLibrary.h" | ||
|
||
@class FIRApp; | ||
@class FIRSegmentation; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// Provides and creates instances of Segmentation. Used in the | ||
/// interop registration process to keep track of Segmentation instances for each `FIRApp` instance. | ||
@protocol FIRSegmentationProvider | ||
|
||
/// Cached instances of Segmentation objects. | ||
@property(nonatomic, strong) NSMutableDictionary<NSString *, FIRSegmentation *> *instances; | ||
|
||
/// Default method for retrieving a Segmentation instance, or creating one if it doesn't exist. | ||
- (FIRSegmentation *)segmentation; | ||
|
||
@end | ||
|
||
/// A concrete implementation for FIRSegmentationInterop to create Segmentation instances and | ||
/// register with Core's component system. | ||
@interface FIRSegmentationComponent : NSObject <FIRSegmentationProvider, FIRLibrary> | ||
|
||
/// The FIRApp that instances will be set up with. | ||
@property(nonatomic, weak, readonly) FIRApp *app; | ||
|
||
/// Cached instances of Segmentation objects. | ||
@property(nonatomic, strong) FIRSegmentation *segmentationInstance; | ||
|
||
/// Default method for retrieving a Segmentation instance, or creating one if it doesn't exist. | ||
- (FIRSegmentation *)segmentation; | ||
|
||
/// Default initializer. | ||
- (instancetype)initWithApp:(FIRApp *)app NS_DESIGNATED_INITIALIZER; | ||
|
||
- (instancetype)init __attribute__((unavailable("Use `initWithApp:`."))); | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
30 changes: 30 additions & 0 deletions
30
FirebaseSegmentation/Sources/Private/FIRSegmentationInternal.h
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2019 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class FIRApp; | ||
|
||
NS_SWIFT_NAME(Segmentation) | ||
@interface FIRSegmentation : NSObject | ||
|
||
/// Initialize a Segmentation instance with all the required parameters directly. | ||
- (instancetype)initWithAppName:(NSString *)appName FIROptions:(FIROptions *)options; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.