Skip to content

Commit 7f0c933

Browse files
committed
Merge branch 'master' into varconst/write-batch-opt-1
2 parents 8283a7b + a3f792f commit 7f0c933

28 files changed

+444
-163
lines changed

Example/Messaging/Tests/FIRMessagingTest.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#import <XCTest/XCTest.h>
1818

1919
#import <OCMock/OCMock.h>
20+
21+
#import <FirebaseCore/FIRAppInternal.h>
2022
#import <FirebaseInstanceID/FirebaseInstanceID.h>
2123

2224
#import "FIRMessaging.h"
@@ -44,13 +46,17 @@ @interface FIRMessagingTest : XCTestCase
4446
@property(nonatomic, readonly, strong) FIRMessaging *messaging;
4547
@property(nonatomic, readwrite, strong) id mockMessaging;
4648
@property(nonatomic, readwrite, strong) id mockInstanceID;
49+
@property(nonatomic, readwrite, strong) id mockFirebaseApp;
4750

4851
@end
4952

5053
@implementation FIRMessagingTest
5154

5255
- (void)setUp {
5356
[super setUp];
57+
_mockFirebaseApp = OCMClassMock([FIRApp class]);
58+
OCMStub([_mockFirebaseApp defaultApp]).andReturn(_mockFirebaseApp);
59+
5460
_messaging = [[FIRMessaging alloc] initWithInstanceID:[FIRInstanceID instanceID]
5561
userDefaults:[NSUserDefaults standardUserDefaults]];
5662
_mockMessaging = OCMPartialMock(self.messaging);
@@ -63,6 +69,7 @@ - (void)setUp {
6369
- (void)tearDown {
6470
[_mockMessaging stopMocking];
6571
[_mockInstanceID stopMocking];
72+
[_mockFirebaseApp stopMocking];
6673
[super tearDown];
6774
}
6875

@@ -76,7 +83,7 @@ - (void)testAutoInitEnableFlag {
7683
}
7784

7885
- (void)testAutoInitEnableFlagOverrideGlobalTrue {
79-
OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES);
86+
OCMStub([_mockFirebaseApp isAutomaticDataCollectionEnabled]).andReturn(YES);
8087
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
8188
OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil);
8289
XCTAssertTrue(self.messaging.isAutoInitEnabled);
@@ -87,7 +94,7 @@ - (void)testAutoInitEnableFlagOverrideGlobalTrue {
8794
}
8895

8996
- (void)testAutoInitEnableFlagOverrideGlobalFalse {
90-
OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES);
97+
OCMStub([_mockFirebaseApp isAutomaticDataCollectionEnabled]).andReturn(YES);
9198
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
9299
OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil);
93100
XCTAssertTrue(self.messaging.isAutoInitEnabled);
@@ -98,7 +105,7 @@ - (void)testAutoInitEnableFlagOverrideGlobalFalse {
98105
}
99106

100107
- (void)testAutoInitEnableGlobalDefaultTrue {
101-
OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES);
108+
OCMStub([_mockFirebaseApp isAutomaticDataCollectionEnabled]).andReturn(YES);
102109
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
103110
OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil);
104111

@@ -107,7 +114,7 @@ - (void)testAutoInitEnableGlobalDefaultTrue {
107114
}
108115

109116
- (void)testAutoInitEnableGlobalDefaultFalse {
110-
OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(NO);
117+
OCMStub([_mockFirebaseApp isAutomaticDataCollectionEnabled]).andReturn(NO);
111118
id bundleMock = OCMPartialMock([NSBundle mainBundle]);
112119
OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil);
113120

Example/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target 'Core_Example_iOS' do
1212
# The next line is the forcing function for the Firebase pod. The Firebase
1313
# version's subspecs should depend on the component versions in their
1414
# corresponding podspec's.
15-
pod 'Firebase/Core', '5.3.0'
15+
pod 'Firebase/Core', '5.4.0'
1616

1717
target 'Core_Tests_iOS' do
1818
inherit! :search_paths

Firebase/Core/FIROptions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
NSString *const kFIRLibraryVersionID =
4444
@"5" // Major version (one or more digits)
4545
@"00" // Minor version (exactly 2 digits)
46-
@"04" // Build number (exactly 2 digits)
46+
@"05" // Build number (exactly 2 digits)
4747
@"000"; // Fixed "000"
4848
// Plist file name.
4949
NSString *const kServiceInfoFileName = @"GoogleService-Info";

Firebase/Messaging/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- Fixed an issue where Messaging wouldn't properly unswizzle swizzled delegate
3+
methods. (#1481)
4+
15
# 2018-07-10 -- v3.0.3
26
- Fixed an issue that client should suspend the topic requests when token is not available and resume the topic operation when the token is generated.
37
- Corrected the deprecation warning when subscribing to or unsubscribing from an invalid topic. (#1397)

Firebase/Messaging/FIRMessaging+FIRApp.m

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
#import "FIRMessagingVersionUtilities.h"
2727
#import "FIRMessaging_Private.h"
2828

29-
@interface FIRMessaging ()
30-
31-
@property(nonatomic, readwrite, strong) NSString *fcmSenderID;
32-
33-
@end
34-
3529
@implementation FIRMessaging (FIRApp)
3630

3731
+ (void)load {
@@ -58,22 +52,6 @@ + (void)didReceiveConfigureSDKNotification:(NSNotification *)notification {
5852
}
5953

6054
- (void)configureMessaging:(FIRApp *)app {
61-
FIROptions *options = app.options;
62-
NSError *error;
63-
if (!options.GCMSenderID.length) {
64-
error =
65-
[FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseCloudMessagingErrorDomain
66-
errorCode:FIRErrorCodeCloudMessagingFailed
67-
service:kFIRServiceMessaging
68-
reason:@"Google Sender ID must not be nil"
69-
@" or empty."];
70-
[self exitApp:app withError:error];
71-
return;
72-
}
73-
74-
self.fcmSenderID = [options.GCMSenderID copy];
75-
self.globalAutomaticDataCollectionEnabled = [app isAutomaticDataCollectionEnabled];
76-
7755
// Swizzle remote-notification-related methods (app delegate and UNUserNotificationCenter)
7856
if ([FIRMessagingRemoteNotificationsProxy canSwizzleMethods]) {
7957
NSString *docsURLString = @"https://firebase.google.com/docs/cloud-messaging/ios/client"

Firebase/Messaging/FIRMessaging.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#import "FIRMessagingUtilities.h"
3737
#import "FIRMessagingVersionUtilities.h"
3838

39+
#import <FirebaseCore/FIRAppInternal.h>
3940
#import <FirebaseCore/FIRReachabilityChecker.h>
4041
#import <FirebaseInstanceID/FirebaseInstanceID.h>
4142

@@ -127,7 +128,6 @@ @interface FIRMessaging ()<FIRMessagingClientDelegate, FIRMessagingReceiverDeleg
127128
FIRReachabilityDelegate>
128129

129130
// FIRApp properties
130-
@property(nonatomic, readwrite, copy) NSString *fcmSenderID;
131131
@property(nonatomic, readwrite, strong) NSData *apnsTokenData;
132132
@property(nonatomic, readwrite, strong) NSString *defaultFcmToken;
133133

@@ -173,10 +173,6 @@ - (instancetype)initWithInstanceID:(FIRInstanceID *)instanceID
173173
_loggedMessageIDs = [NSMutableSet set];
174174
_instanceID = instanceID;
175175
_messagingUserDefaults = defaults;
176-
177-
// TODO: Remove this once the race condition with FIRApp configuring and InstanceID
178-
// is fixed. This must be fixed before Core's flag becomes public.
179-
_globalAutomaticDataCollectionEnabled = YES;
180176
}
181177
return self;
182178
}
@@ -479,7 +475,7 @@ - (BOOL)isAutoInitEnabled {
479475
}
480476

481477
// If none of above exists, we default to the global switch that comes from FIRApp.
482-
return self.isGlobalAutomaticDataCollectionEnabled;
478+
return [[FIRApp defaultApp] isAutomaticDataCollectionEnabled];
483479
}
484480

485481
- (void)setAutoInitEnabled:(BOOL)autoInitEnabled {

Firebase/Messaging/FIRMessagingRemoteNotificationsProxy.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ - (void)listenForDelegateChangesInUserNotificationCenter:(id)notificationCenter
211211

212212
#pragma mark - UNNotificationCenter Swizzling
213213

214-
- (void)swizzleUserNotificationCenterDelegate:(id)delegate {
214+
- (void)swizzleUserNotificationCenterDelegate:(id _Nonnull)delegate {
215215
if (self.currentUserNotificationCenterDelegate == delegate) {
216216
// Via pointer-check, compare if we have already swizzled this item.
217217
return;
@@ -246,7 +246,7 @@ - (void)swizzleUserNotificationCenterDelegate:(id)delegate {
246246
}
247247
}
248248

249-
- (void)unswizzleUserNotificationCenterDelegate:(id)delegate {
249+
- (void)unswizzleUserNotificationCenterDelegate:(id _Nonnull)delegate {
250250
if (self.currentUserNotificationCenterDelegate != delegate) {
251251
// We aren't swizzling this delegate, so don't do anything.
252252
return;
@@ -256,6 +256,10 @@ - (void)unswizzleUserNotificationCenterDelegate:(id)delegate {
256256
// Call unswizzle methods, even if the method was not implemented (it will fail gracefully).
257257
[self unswizzleSelector:willPresentNotificationSelector
258258
inClass:[self.currentUserNotificationCenterDelegate class]];
259+
SEL didReceiveNotificationResponseSelector =
260+
NSSelectorFromString(kUserNotificationDidReceiveResponseSelectorString);
261+
[self unswizzleSelector:didReceiveNotificationResponseSelector
262+
inClass:[self.currentUserNotificationCenterDelegate class]];
259263
self.currentUserNotificationCenterDelegate = nil;
260264
self.hasSwizzledUserNotificationDelegate = NO;
261265
}

Firebase/Messaging/FIRMessaging_Private.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ FOUNDATION_EXPORT NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled;
3838

3939
#pragma mark - Private API
4040

41-
// The data collection flag from Core.
42-
@property(nonatomic, readwrite, getter=isGlobalAutomaticDataCollectionEnabled) BOOL globalAutomaticDataCollectionEnabled;
43-
4441
- (NSString *)defaultFcmToken;
4542
- (FIRMessagingClient *)client;
4643
- (FIRMessagingPubSub *)pubsub;

FirebaseAuth.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseAuth'
3-
s.version = '5.0.1'
3+
s.version = '5.0.2'
44
s.summary = 'The official iOS client for Firebase Authentication (plus community support for macOS and tvOS)'
55

66
s.description = <<-DESC

FirebaseCore.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseCore'
3-
s.version = '5.0.4'
3+
s.version = '5.0.5'
44
s.summary = 'Firebase Core for iOS (plus community support for macOS and tvOS)'
55

66
s.description = <<-DESC
@@ -35,6 +35,6 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration
3535
s.pod_target_xcconfig = {
3636
'OTHER_CFLAGS' => '-fno-autolink',
3737
'GCC_PREPROCESSOR_DEFINITIONS' =>
38-
'FIRCore_VERSION=' + s.version.to_s + ' Firebase_VERSION=5.3.0'
38+
'FIRCore_VERSION=' + s.version.to_s + ' Firebase_VERSION=5.4.0'
3939
}
4040
end

FirebaseDatabase.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseDatabase'
3-
s.version = '5.0.1'
3+
s.version = '5.0.2'
44
s.summary = 'Firebase Open Source Libraries for iOS (plus community support for macOS and tvOS)'
55

66
s.description = <<-DESC

FirebaseFirestore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseFirestore'
3-
s.version = '0.12.4'
3+
s.version = '0.12.5'
44
s.summary = 'Google Cloud Firestore for iOS'
55

66
s.description = <<-DESC

FirebaseFunctions.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseFunctions'
3-
s.version = '2.0.0'
3+
s.version = '2.1.0'
44
s.summary = 'Cloud Functions for Firebase iOS SDK.'
55

66
s.description = <<-DESC

FirebaseMessaging.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseMessaging'
3-
s.version = '3.0.2'
3+
s.version = '3.0.3'
44
s.summary = 'Firebase Messaging for iOS'
55

66
s.description = <<-DESC

Firestore/Example/FuzzTests/FSTFuzzTestsPrincipal.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,27 @@
1818

1919
#include "LibFuzzer/FuzzerDefs.h"
2020

21+
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
2122
#include "Firestore/core/src/firebase/firestore/remote/serializer.h"
2223

24+
using firebase::firestore::model::DatabaseId;
2325
using firebase::firestore::remote::Serializer;
2426

2527
namespace {
2628

2729
// Fuzz-test the deserialization process in Firestore. The Serializer reads raw
2830
// bytes and converts them to a model object.
2931
void FuzzTestDeserialization(const uint8_t *data, size_t size) {
30-
// TODO(minafarid): fuzz-test Serializer.
32+
DatabaseId database_id{"project", DatabaseId::kDefault};
33+
Serializer serializer{database_id};
34+
35+
@try {
36+
serializer.DecodeFieldValue(data, size);
37+
} @catch (...) {
38+
// Caught exceptions are ignored because the input might be malformed and
39+
// the deserialization might throw an error as intended. Fuzzing focuses on
40+
// runtime errors that are detected by the sanitizers.
41+
}
3142
}
3243

3344
// Contains the code to be fuzzed. Called by the fuzzing library with

Firestore/Example/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ target 'Firestore_Example_iOS' do
1010
# The next line is the forcing function for the Firebase pod. The Firebase
1111
# version's subspecs should depend on the component versions in their
1212
# corresponding podspec's.
13-
pod 'Firebase/Core', '5.3.0'
13+
pod 'Firebase/Core', '5.4.0'
1414

1515
pod 'FirebaseAuth', :path => '../../'
1616
pod 'FirebaseCore', :path => '../../'

Firestore/core/src/firebase/firestore/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ cc_library(
1919
database_info.h
2020
target_id_generator.cc
2121
target_id_generator.h
22+
query.cc
23+
query.h
2224
DEPENDS
2325
absl_strings
2426
firebase_firestore_model
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "Firestore/core/src/firebase/firestore/core/query.h"
18+
19+
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
20+
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
21+
22+
namespace firebase {
23+
namespace firestore {
24+
namespace core {
25+
26+
using model::Document;
27+
using model::DocumentKey;
28+
using model::ResourcePath;
29+
30+
bool Query::Matches(const Document& doc) const {
31+
return MatchesPath(doc) && MatchesOrderBy(doc) && MatchesFilters(doc) &&
32+
MatchesBounds(doc);
33+
}
34+
35+
bool Query::MatchesPath(const Document& doc) const {
36+
ResourcePath doc_path = doc.key().path();
37+
if (DocumentKey::IsDocumentKey(path_)) {
38+
return path_ == doc_path;
39+
} else {
40+
return path_.IsPrefixOf(doc_path) && path_.size() == doc_path.size() - 1;
41+
}
42+
}
43+
44+
bool Query::MatchesFilters(const Document&) const {
45+
// TODO(rsgowman): Implement this correctly.
46+
return true;
47+
}
48+
49+
bool Query::MatchesOrderBy(const Document&) const {
50+
// TODO(rsgowman): Implement this correctly.
51+
return true;
52+
}
53+
54+
bool Query::MatchesBounds(const Document&) const {
55+
// TODO(rsgowman): Implement this correctly.
56+
return true;
57+
}
58+
59+
} // namespace core
60+
} // namespace firestore
61+
} // namespace firebase

0 commit comments

Comments
 (0)