diff --git a/.travis.yml b/.travis.yml index 986d6ba674d..1626d37a706 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,6 +87,15 @@ jobs: - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseDynamicLinks.podspec - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseDynamicLinks.podspec --use-libraries - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseDynamicLinks.podspec --use-modular-headers + + env: + - PROJECT=Segmentation PLATFORM=all METHOD=pod-lib-lint + before_install: + - ./scripts/if_changed.sh ./scripts/install_prereqs.sh + script: + - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseSegmentation.podspec + - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseSegmentation.podspec --use-libraries + - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseSegmentation.podspec --use-modular-headers - stage: test env: @@ -433,3 +442,4 @@ jobs: branches: only: - master + - md-floc-master diff --git a/FirebaseSegmentation.podspec b/FirebaseSegmentation.podspec new file mode 100644 index 00000000000..9bbe5c219c3 --- /dev/null +++ b/FirebaseSegmentation.podspec @@ -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' + s.static_framework = true + s.prefix_header_file = false + + s.source_files = 'FirebaseSegmentation/Sources/**/*' + s.public_header_files = 'FirebaseSegmentation/Public/*.h' + + s.dependency 'FirebaseCore', '~> 6.0' + s.dependency 'FirebaseInstanceID', '~> 4.2' + + header_search_paths = { + 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"' + } + +s.user_target_xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '$(PLATFORM_DIR)/Developer/Library/Frameworks' } + + s.pod_target_xcconfig = { + 'GCC_C_LANGUAGE_STANDARD' => 'c99', + 'GCC_PREPROCESSOR_DEFINITIONS' => 'FIRSegmentation_VERSION=' + s.version.to_s + } + + s.test_spec 'unit' do |unit_tests| + unit_tests.source_files = 'FirebaseSegmentation/Tests/Unit/*.[mh]' + unit_tests.dependency 'OCMock' + end + +end diff --git a/FirebaseSegmentation/Public/FIRSegmentation.h b/FirebaseSegmentation/Public/FIRSegmentation.h new file mode 100644 index 00000000000..10c152d594a --- /dev/null +++ b/FirebaseSegmentation/Public/FIRSegmentation.h @@ -0,0 +1,64 @@ +/* + * 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 + +NS_ASSUME_NONNULL_BEGIN + +@class FIRApp; +/** + * The Firebase Segmentation SDK is used to associate a custom, non-Firebase custom installation + * identifier to Firebase. Once this custom installation identifier is set, developers can use the + * current app installation for segmentation purposes. If the custom installation identifier is + * explicitely set to nil, any existing custom installation identifier data will be removed. + */ +NS_SWIFT_NAME(Segmentation) +@interface FIRSegmentation : NSObject + +/** + * Singleton instance (scoped to the default FIRApp) + * Returns the FIRSegmentation instance for the default Firebase application. Please make sure you + * call [FIRApp configure] beforehand for a default Firebase app to already be initialized and + * available. This singleton class instance lets you set your own custom identifier to be used for + * user segmentation purposes within Firebase. + * + * @return A shared instance of FIRSegmentation. + */ ++ (nonnull FIRSegmentation *)segmentation NS_SWIFT_NAME(segmentation()); + +/// Singleton instance (scoped to FIRApp) +/// Returns the FIRSegmentation instance for your Firebase application. This singleton class +/// instance lets you set your own custom identifier to be used for targeting purposes within +/// Firebase. ++ (nonnull FIRSegmentation *)segmentationWithApp:(nonnull FIRApp *)app + NS_SWIFT_NAME(segmentation(app:)); + +/** + * Unavailable. Use +segmentation instead. + */ +- (instancetype)init __attribute__((unavailable("Use +segmentation instead."))); + +/// Set your own custom installation ID to be used for segmentation purposes. +/// This method needs to be called every time (and immediately) upon any changes to the custom +/// installation ID. +/// @param completionHandler Set custom installation ID completion. Returns nil if initialization +/// succeeded or an NSError object if initialization failed. +- (void)setCustomInstallationID:(NSString *)customInstallationID + completion:(void (^)(NSError *))completionHandler; + +@end + +NS_ASSUME_NONNULL_END diff --git a/FirebaseSegmentation/Public/FirebaseSegmentation.h b/FirebaseSegmentation/Public/FirebaseSegmentation.h new file mode 100644 index 00000000000..31465cbb877 --- /dev/null +++ b/FirebaseSegmentation/Public/FirebaseSegmentation.h @@ -0,0 +1,17 @@ +/* + * 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 "FIRSegmentation.h" diff --git a/FirebaseSegmentation/Sources/CHANGELOG.md b/FirebaseSegmentation/Sources/CHANGELOG.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/FirebaseSegmentation/Sources/FIRSegmentation.m b/FirebaseSegmentation/Sources/FIRSegmentation.m new file mode 100644 index 00000000000..f136a95ccdd --- /dev/null +++ b/FirebaseSegmentation/Sources/FIRSegmentation.m @@ -0,0 +1,15 @@ +// 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 "FIRSegmentation.h" diff --git a/FirebaseSegmentation/Tests/Unit/SEGInitializationTests.m b/FirebaseSegmentation/Tests/Unit/SEGInitializationTests.m new file mode 100644 index 00000000000..8cc2efd23fe --- /dev/null +++ b/FirebaseSegmentation/Tests/Unit/SEGInitializationTests.m @@ -0,0 +1,46 @@ +// 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 + +@interface SEGInitializationTests : XCTestCase + +@end + +@implementation SEGInitializationTests + +- (void)setUp { + // Put setup code here. This method is called before the invocation of each test method in the + // class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the + // class. +} + +- (void)testExample { + NSLog(@"this is a test example"); + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end