Skip to content

Commit cb3699e

Browse files
committed
Merge github.com:firebase/firebase-ios-sdk
2 parents ff27092 + d8120ad commit cb3699e

File tree

102 files changed

+946
-305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+946
-305
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ template_path=.github/ISSUE_TEMPLATE/bug_report.md
2525

2626
* Xcode version: _____
2727
* Firebase SDK version: _____
28-
* Firebase Component: _____ (Auth, Core, Database, Firestore, Messaging, Storage, etc)
29-
* Component version: _____
3028
* Installation method: `CocoaPods | Carthage | Zip file | Swift Package Manager` (select one)
29+
* Firebase Component: _____ (Auth, Core, Database, Firestore, Messaging, Storage, etc)
3130

3231
### [REQUIRED] Step 2: Describe the problem
3332

.github/workflows/check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
paths-ignore:
66
- 'Firestore/**'
7+
push:
8+
branches: master
79

810
jobs:
911
check:

.github/workflows/firestore.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ jobs:
196196
# Don't run on private repo unless it is a PR.
197197
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
198198
runs-on: macOS-latest
199+
needs: check
199200
steps:
200201
- uses: actions/checkout@v2
201202
- name: Xcode 12
@@ -205,7 +206,7 @@ jobs:
205206
- name: iOS Build Test
206207
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore iOS spmbuildonly
207208
- name: Swift Build
208-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift iOS spmbuildonly
209+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift-Beta iOS spmbuildonly
209210

210211
spm-cron:
211212
# Don't run on private repo.
@@ -223,7 +224,7 @@ jobs:
223224
- name: Build Test
224225
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore ${{ matrix.target }} spmbuildonly
225226
- name: Swift Build
226-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly
227+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift-Beta ${{ matrix.target }} spmbuildonly
227228

228229
# Restore when FirebaseUI works with Firebase 7 (#6646)
229230
quickstart:

.github/workflows/storage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: iOS Unit Tests
5555
run: scripts/third_party/travis/retry.sh ./scripts/build.sh StorageUnit iOS spm
5656
- name: Swift Build
57-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseStorageSwift iOS spmbuildonly
57+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseStorageSwift-Beta iOS spmbuildonly
5858

5959
spm-cron:
6060
# Don't run on private repo.
@@ -72,7 +72,7 @@ jobs:
7272
- name: Unit Tests
7373
run: scripts/third_party/travis/retry.sh ./scripts/build.sh StorageUnit ${{ matrix.target }} spm
7474
- name: Swift Build
75-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseStorageSwift ${{ matrix.target }} spmbuildonly
75+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseStorageSwift-Beta ${{ matrix.target }} spmbuildonly
7676

7777
catalyst:
7878
# Don't run on private repo unless it is a PR.

Crashlytics/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22
- [fixed] Fixed an issue where symbol uploads would fail when there are spaces in the project path, particularly in Unity builds (#6789).
3+
- [changed] Added additional logging when settings requests fail with a 404 status to help customers debug onboarding issues (#6847).
34

45
# v4.6.2
56

Crashlytics/Crashlytics/Settings/FIRCLSSettingsOnboardingManager.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ - (void)onboardingOperation:(FIRCLSOnboardingOperation *)operation
181181
- (void)operation:(FIRCLSDownloadAndSaveSettingsOperation *)operation
182182
didDownloadAndSaveSettingsWithError:(nullable NSError *)error {
183183
if (error) {
184-
FIRCLSErrorLog(@"Failed to download settings %@", error);
184+
NSString *message = @"Failed to download settings.";
185+
if (error.userInfo && [error.userInfo objectForKey:@"status_code"] &&
186+
[[error.userInfo objectForKey:@"status_code"]
187+
isEqualToNumber:[NSNumber numberWithInt:404]]) {
188+
NSString *debugHint = @"If this is your first time launching the app, make sure you have "
189+
@"enabled Crashlytics in the Firebase Console.";
190+
message = [NSString stringWithFormat:@"%@ %@", message, debugHint];
191+
}
192+
FIRCLSErrorLog(@"%@ %@", message, error);
185193
[self finishNetworkingSession];
186194
return;
187195
}

FirebaseDynamicLinks/Sources/FIRDynamicLinks.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,22 @@ - (BOOL)handleIncomingCustomSchemeDeepLink:(NSURL *)url {
509509
}
510510

511511
- (void)passRetrievedDynamicLinkToApplication:(NSURL *)url {
512+
id<UIApplicationDelegate> applicationDelegate = [UIApplication sharedApplication].delegate;
513+
if ([self isOpenUrlMethodPresentInAppDelegate:applicationDelegate]) {
514+
// pass url directly to application delegate to avoid hop into
515+
// iOS handling of the universal links
516+
[applicationDelegate application:[UIApplication sharedApplication] openURL:url options:@{}];
517+
return;
518+
}
519+
512520
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
513521
}
514522

523+
- (BOOL)isOpenUrlMethodPresentInAppDelegate:(id<UIApplicationDelegate>)applicationDelegate {
524+
return applicationDelegate &&
525+
[applicationDelegate respondsToSelector:@selector(application:openURL:options:)];
526+
}
527+
515528
- (void)handlePendingDynamicLinkRetrievalFailureWithErrorCode:(NSInteger)errorCode
516529
errorDescription:(NSString *)errorDescription
517530
underlyingError:(nullable NSError *)underlyingError {
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# Uncomment the next line to define a global platform for your project
2-
# platform :ios, '9.0'
3-
41
target 'FDLBuilderTestAppObjC' do
5-
# Comment the next line if you don't want to use dynamic frameworks
2+
platform :ios, '10.0'
63
use_frameworks!
7-
pod 'FirebaseAnalytics'
4+
85
pod 'FirebaseCore', :path => '../../../'
9-
pod 'FirebaseInstallations', :path => '../../../'
10-
pod 'FirebaseInstanceID', :path => '../../../'
11-
pod 'FirebaseDynamicLinks', :path => '../../../'
6+
pod 'FirebaseCoreDiagnostics', :path => '../../../'
7+
pod 'GoogleDataTransport', :path => '../../../'
128
pod 'GoogleUtilities', :path => '../../../'
13-
9+
pod 'FirebaseDynamicLinks', :path => '../../../'
1410
end

FirebaseDynamicLinks/Tests/Unit/FIRDynamicLinksTest.m

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ - (BOOL)setUpWithLaunchOptions:(nullable NSDictionary *)launchOptions
7979
urlScheme:(nullable NSString *)urlScheme
8080
userDefaults:(nullable NSUserDefaults *)userDefaults;
8181
- (BOOL)canParseUniversalLinkURL:(nullable NSURL *)url;
82+
- (void)passRetrievedDynamicLinkToApplication:(NSURL *)url;
83+
- (BOOL)isOpenUrlMethodPresentInAppDelegate:(id<UIApplicationDelegate>)applicationDelegate;
8284
@end
8385

8486
@interface FakeShortLinkResolver : FIRDynamicLinkNetworking
@@ -1119,7 +1121,7 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
11191121
apiKey:kAPIKey
11201122
urlScheme:nil
11211123
userDefaults:[NSUserDefaults standardUserDefaults]];
1122-
FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *deleagte =
1124+
FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *delegate =
11231125
(FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *)self.service;
11241126

11251127
// Error Result to pass
@@ -1131,13 +1133,36 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
11311133

11321134
FIRDLDefaultRetrievalProcessV2 *defaultRetrievalProcess = [FIRDLDefaultRetrievalProcessV2 alloc];
11331135

1134-
[deleagte retrievalProcess:defaultRetrievalProcess completedWithResult:result];
1136+
[delegate retrievalProcess:defaultRetrievalProcess completedWithResult:result];
11351137

11361138
NSString *kFIRDLOpenURLKey = @"com.google.appinvite.openURL";
11371139
XCTAssertEqual([[NSUserDefaults standardUserDefaults] boolForKey:kFIRDLOpenURLKey], YES,
11381140
@"kFIRDLOpenURL key should be set regardless of failures");
11391141
}
11401142

1143+
- (void)test_passRetrievedDynamicLinkToApplicationDelegatesProperly {
1144+
// Creating ApplicationDelegate partial mock object.
1145+
id applicationDelegate = OCMPartialMock([UIApplication sharedApplication].delegate);
1146+
// Creating FIRDynamicLinks partial mock object.
1147+
id firebaseDynamicLinks = OCMPartialMock(self.service);
1148+
// Stubbing Application delegate to return YES when application:openURL:options method is called.
1149+
// Not sure why this is required as we are not concerned about its return, but without this, the
1150+
// test will throw NSInvalidArgumentException with message "unrecognized selector sent to
1151+
// instance".
1152+
OCMStub([applicationDelegate application:[OCMArg any] openURL:[OCMArg any] options:[OCMArg any]])
1153+
.andReturn(YES);
1154+
// Stubbing firebase dynamiclinks instance to return YES when isOpenUrlMethodPresentInAppDelegate
1155+
// is called.
1156+
OCMStub([firebaseDynamicLinks isOpenUrlMethodPresentInAppDelegate:[OCMArg any]]).andReturn(YES);
1157+
1158+
// Executing the function with a URL.
1159+
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
1160+
[firebaseDynamicLinks passRetrievedDynamicLinkToApplication:url];
1161+
1162+
// Verifying the application:openURL:options method is called in AppDelegate.
1163+
OCMVerify([applicationDelegate application:[OCMArg any] openURL:url options:[OCMArg any]]);
1164+
}
1165+
11411166
#pragma mark - Self-diagnose tests
11421167

11431168
- (void)testSelfDiagnoseWithNilCompletion {

FirebaseFirestore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
7272
s.dependency 'leveldb-library', '~> 1.22'
7373
s.dependency 'nanopb', '~> 2.30906.0'
7474

75-
s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration', 'UIKit'
75+
s.ios.frameworks = 'SystemConfiguration', 'UIKit'
7676
s.osx.frameworks = 'SystemConfiguration'
7777
s.tvos.frameworks = 'SystemConfiguration', 'UIKit'
7878

FirebaseRemoteConfig.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ app update.
5454
# 'FirebaseRemoteConfig/Tests/Unit/RCNConfigTest.m',
5555
'FirebaseRemoteConfig/Tests/Unit/RCNConfigExperimentTest.m',
5656
'FirebaseRemoteConfig/Tests/Unit/RCNConfigValueTest.m',
57+
'FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m',
5758
# 'FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfig+FIRAppTest.m',
5859
'FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m',
5960
# 'FirebaseRemoteConfig/Tests/Unit/RCNThrottlingTests.m',

FirebaseRemoteConfig/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v7.1.0
2+
- [changed] Add support for other Firebase products to integrate with Remote Config. (#6692)
3+
14
# v7.0.0
25
- [changed] Updated `lastFetchTime` field to readonly. (#6567)
36
- [changed] Functionally neutral change to stop using a deprecated method in the AB Testing API. (#6543)

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
2929
#import "FirebaseRemoteConfig/Sources/RCNConfigValue_Internal.h"
3030
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
31+
#import "FirebaseRemoteConfig/Sources/RCNPersonalization.h"
3132

3233
/// Remote Config Error Domain.
3334
/// TODO: Rename according to obj-c style for constants.
@@ -39,6 +40,9 @@
3940
/// Timeout value for waiting on a fetch response.
4041
static NSString *const kRemoteConfigFetchTimeoutKey = @"_rcn_fetch_timeout";
4142

43+
/// Listener for the get methods.
44+
typedef void (^FIRRemoteConfigListener)(NSString *_Nonnull, NSDictionary *_Nonnull);
45+
4246
@implementation FIRRemoteConfigSettings
4347

4448
- (instancetype)init {
@@ -61,6 +65,7 @@ @implementation FIRRemoteConfig {
6165
RCNConfigExperiment *_configExperiment;
6266
dispatch_queue_t _queue;
6367
NSString *_appName;
68+
NSMutableArray *_listeners;
6469
}
6570

6671
static NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, FIRRemoteConfig *> *>
@@ -154,6 +159,15 @@ - (instancetype)initWithAppName:(NSString *)appName
154159
options:options];
155160

156161
[_settings loadConfigFromMetadataTable];
162+
163+
if (analytics) {
164+
_listeners = [[NSMutableArray alloc] init];
165+
RCNPersonalization *personalization =
166+
[[RCNPersonalization alloc] initWithAnalytics:analytics];
167+
[self addListener:^(NSString *key, NSDictionary *config) {
168+
[personalization logArmActive:key config:config];
169+
}];
170+
}
157171
}
158172
return self;
159173
}
@@ -185,6 +199,24 @@ - (void)ensureInitializedWithCompletionHandler:
185199
});
186200
}
187201

202+
/// Adds a listener that will be called whenever one of the get methods is called.
203+
/// @param listener Function that takes in the parameter key and the config.
204+
- (void)addListener:(nonnull FIRRemoteConfigListener)listener {
205+
@synchronized(_listeners) {
206+
[_listeners addObject:listener];
207+
}
208+
}
209+
210+
- (void)callListeners:(NSString *)key config:(NSDictionary *)config {
211+
@synchronized(_listeners) {
212+
for (FIRRemoteConfigListener listener in _listeners) {
213+
dispatch_async(_queue, ^{
214+
listener(key, config);
215+
});
216+
}
217+
}
218+
}
219+
188220
#pragma mark - fetch
189221

190222
- (void)fetchWithCompletionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
@@ -279,6 +311,7 @@ - (void)activateWithCompletion:(FIRRemoteConfigActivateChangeCompletion)completi
279311
forNamespace:self->_FIRNamespace];
280312
strongSelf->_settings.lastApplyTimeInterval = [[NSDate date] timeIntervalSince1970];
281313
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000069", @"Config activated.");
314+
[strongSelf->_configContent activatePersonalization];
282315
[strongSelf->_configExperiment updateExperimentsWithHandler:^(NSError *_Nullable error) {
283316
if (completion) {
284317
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -321,6 +354,8 @@ - (FIRRemoteConfigValue *)configValueForKey:(NSString *)key {
321354
@"Key %@ should come from source:%zd instead coming from source: %zd.", key,
322355
(long)FIRRemoteConfigSourceRemote, (long)value.source);
323356
}
357+
[self callListeners:key
358+
config:[self->_configContent getConfigAndMetadataForNamespace:FQNamespace]];
324359
return;
325360
}
326361
value = self->_configContent.defaultConfig[FQNamespace][key];

FirebaseRemoteConfig/Sources/RCNConfigConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static const char *RCNRemoteConfigQueueLabel = "com.google.GoogleConfigService.F
3535
static NSString *const RCNFetchResponseKeyEntries = @"entries";
3636
/// Key that includes data for experiment descriptions in ABT.
3737
static NSString *const RCNFetchResponseKeyExperimentDescriptions = @"experimentDescriptions";
38+
/// Key that includes data for Personalization metadata.
39+
static NSString *const RCNFetchResponseKeyPersonalizationMetadata = @"personalizationMetadata";
3840
/// Error key.
3941
static NSString *const RCNFetchResponseKeyError = @"error";
4042
/// Error code.

FirebaseRemoteConfig/Sources/RCNConfigContent.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ typedef NS_ENUM(NSInteger, RCNDBSource) {
5757
toSource:(RCNDBSource)source
5858
forNamespace:(NSString *)FIRNamespace;
5959

60+
/// Sets the fetched Personalization metadata to active.
61+
- (void)activatePersonalization;
62+
63+
/// Gets the active config and Personalization metadata.
64+
- (NSDictionary *)getConfigAndMetadataForNamespace:(NSString *)FIRNamespace;
65+
6066
@end

0 commit comments

Comments
 (0)