Skip to content

Commit ab8314f

Browse files
authored
Merge public 5 25 (#79)
* Initial commit * Initial * Add three files in repo despite .gitignore * Update README with context, contributing, and license sections (#3) * Updating READMEs (#5) * Add comments to each FIRLoggerLevel value. (#6) Docs aren't being generated properly for FIRLoggerLevel because it's missing the proper documentation. * Update travis for renamed AllUnitTests scheme (#8) * Remove double commented lines. (#11) * Update scheme setting in test.sh (#12) * Update travis xcode version to 8.3 (#13) * Add CI badge to README (#14) * Fix typos (#15) * Adding cache to Travis builds (#17) * Enable direct channel in the sample app (#7) This shows the simple property, shouldEstablishDirectChannel, to open a new channel, and how to show incoming messages with the iOS 10 delegate handler * Auth jazzy fixes and Swift sample updates (#19) * Removes the '@c' that would cause Jazzy issue down the road. * Update travis test to retry if error is 65 (#20) * Fixes ApiTests and separates its credentials from Sample (#25) * Log an error if for some reason we can't add a method to a class (#24) Maybe it was already swizzled, or some other issue. Either way, it would be good to log this error, as it might help us / developers diagnose an issue. * Update FIRPhoneAuthProvider reference docs (#27) Adds reference docs error documentation to FIRPhoneAuthProvider. Also fixes small typo in FIRAuthErrorUtils. * Clean up logging and configuration in Messaging (#28) * Remove mostly unused code from FIRMessagingLogger This cleans up some left-over old logging logic from before we moved to FIRLogger in Firebase Core. We no longer need this logging functionality. * Delete FIRMessagingConfig.{h,m} We no longer need a config class to store an unused log level filter (that filter is no longer needed).
1 parent 4ad418d commit ab8314f

23 files changed

+86
-311
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
osx_image: xcode8.1
1+
osx_image: xcode8.3
22
language: objective-c
3-
# cache: cocoapods
3+
cache:
4+
- bundler
5+
- cocoapods
46
podfile: Example/Podfile
57
xcode_workspace: Example/Firebase.xcworkspace
6-
xcode_scheme: AllTests
8+
xcode_scheme: AllUnitTests
79

810
rvm: 2.3.1
911
before_install:

BuildFrameworks/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
one or more of FirebaseAuth, FirebaseCore, FirebaseDatabase, FirebaseMessaging,
55
and FirebaseStorage.
66

7-
Frameworks built with this script can be used alongside the official Firebase
8-
CocoaPods and
7+
Frameworks built with this script can be used alongside the official [Firebase
8+
CocoaPods](https://cocoapods.org/pods/Firebase) and
99
[zip](https://firebase.google.com/docs/ios/setup#frameworks) distributions.
1010

1111

Example/Messaging/App/AppDelegate.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5050

5151
FirebaseApp.configure()
5252
Messaging.messaging().delegate = self
53+
Messaging.messaging().shouldEstablishDirectChannel = true
5354

5455
NotificationsController.configure()
5556

@@ -110,5 +111,18 @@ extension AppDelegate: MessagingDelegate {
110111
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
111112
printFCMToken()
112113
}
114+
115+
// Direct channel data messages are delivered here, on iOS 10.0+.
116+
// The `shouldEstablishDirectChannel` property should be be set to |true| before data messages can
117+
// arrive.
118+
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
119+
// Convert to pretty-print JSON
120+
guard let data =
121+
try? JSONSerialization.data(withJSONObject: remoteMessage.appData, options: .prettyPrinted),
122+
let prettyPrinted = String(data: data, encoding: .utf8) else {
123+
return
124+
}
125+
print("Received direct channel message:\n\(prettyPrinted)")
126+
}
113127
}
114128

Example/Messaging/Tests/FIRMessagingDataMessageManagerTest.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#import "FIRMessaging.h"
2424
#import "FIRMessagingClient.h"
25-
#import "FIRMessagingConfig.h"
2625
#import "FIRMessagingConnection.h"
2726
#import "FIRMessagingDataMessageManager.h"
2827
#import "FIRMessagingReceiver.h"

Example/Messaging/Tests/FIRMessagingLinkHandlingTest.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
#import <OCMock/OCMock.h>
2020

2121
#import "FIRMessaging.h"
22-
#import "FIRMessagingConfig.h"
2322
#import "FIRMessagingConstants.h"
2423
#import "FIRMessagingTestNotificationUtilities.h"
2524

2625
@interface FIRMessaging ()
2726

28-
- (instancetype)initWithConfig:(FIRMessagingConfig *)config;
27+
- (instancetype)initPrivately;
2928
- (NSURL *)linkURLFromMessage:(NSDictionary *)message;
3029

3130
@end
@@ -41,8 +40,7 @@ @implementation FIRMessagingLinkHandlingTest
4140
- (void)setUp {
4241
[super setUp];
4342

44-
FIRMessagingConfig *config = [FIRMessagingConfig defaultConfig];
45-
_messaging = [[FIRMessaging alloc] initWithConfig:config];
43+
_messaging = [[FIRMessaging alloc] initPrivately];
4644
}
4745

4846
- (void)tearDown {

Example/Messaging/Tests/FIRMessagingServiceTest.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#import "FIRMessaging.h"
2323
#import "FIRMessagingClient.h"
24-
#import "FIRMessagingConfig.h"
2524
#import "FIRMessagingPubSub.h"
2625
#import "FIRMessagingTopicsCommon.h"
2726
#import "InternalHeaders/FIRMessagingInternalUtilities.h"

Example/Messaging/Tests/FIRMessagingTest.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import <OCMock/OCMock.h>
2020

2121
#import "FIRMessaging.h"
22-
#import "FIRMessagingConfig.h"
2322
#import "FIRMessagingInstanceIDProxy.h"
2423

2524
extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
@@ -30,7 +29,7 @@ @interface FIRMessaging ()
3029
@property(nonatomic, readwrite, strong) NSData *apnsTokenData;
3130
@property(nonatomic, readwrite, strong) FIRMessagingInstanceIDProxy *instanceIDProxy;
3231

33-
- (instancetype)initWithConfig:(FIRMessagingConfig *)config;
32+
- (instancetype)initPrivately;
3433
// Direct Channel Methods
3534
- (void)updateAutomaticClientConnection;
3635
- (BOOL)shouldBeConnectedAutomatically;
@@ -49,8 +48,7 @@ @implementation FIRMessagingTest
4948

5049
- (void)setUp {
5150
[super setUp];
52-
FIRMessagingConfig *config = [FIRMessagingConfig defaultConfig];
53-
_messaging = [[FIRMessaging alloc] initWithConfig:config];
51+
_messaging = [[FIRMessaging alloc] initPrivately];
5452
_mockMessaging = OCMPartialMock(self.messaging);
5553
_mockInstanceIDProxy = OCMPartialMock(self.messaging.instanceIDProxy);
5654
self.messaging.instanceIDProxy = _mockInstanceIDProxy;

Firebase/Auth/Docs/threading.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document describes how Firebase Auth maintains thread-safety. The Firebase
44
Auth library (not including Firebase Auth UI and Auth Provider UIs for now)
5-
must be thread-safe, meaning deveopers are free to call any method in any
5+
must be thread-safe, meaning developers are free to call any method in any
66
thread at any time. Thus, all code that may take part in race conditions must
77
be protected in some way.
88

@@ -111,7 +111,7 @@ methods:
111111
* The calling code should already be in the auth global work queue.
112112
* The callback, if any, is provided by our own code, so it expects to called
113113
in the auth global work queue as well. This is usually already the case,
114-
unless the method pass the callback to some other asychronous methods
114+
unless the method pass the callback to some other asynchronous methods
115115
outside our library, in which case we need to manually make the callback
116116
called in the auth global work queue.
117117

Firebase/Auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
Firebase Auth enables apps to easily support multiple authentication options
44
for their end users.
55

6-
Please visit [our developer site](https://developers.google.com/) for
6+
Please visit [our developer site](https://firebase.google.com/docs/auth/) for
77
integration instructions, documentation, support information, and terms of
88
service.

Firebase/Auth/Source/FIRAuthSwiftNameSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#import <Foundation/Foundation.h>
2020

2121
// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK.
22-
// // Wrap it in our own macro if it's a non-compatible SDK.
22+
// Wrap it in our own macro if it's a non-compatible SDK.
2323
#ifdef __IPHONE_9_3
2424
#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
2525
#else

Firebase/Core/FIRCoreSwiftNameSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#import <Foundation/Foundation.h>
2020

2121
// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK.
22-
// // Wrap it in our own macro if it's a non-compatible SDK.
22+
// Wrap it in our own macro if it's a non-compatible SDK.
2323
#ifdef __IPHONE_9_3
2424
#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
2525
#else

Firebase/Core/FIRLoggerLevel.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@
2020
* The log levels used by internal logging.
2121
*/
2222
typedef NS_ENUM(NSInteger, FIRLoggerLevel) {
23-
FIRLoggerLevelError = 3 /*ASL_LEVEL_ERR*/,
24-
FIRLoggerLevelWarning = 4 /*ASL_LEVEL_WARNING*/,
25-
FIRLoggerLevelNotice = 5 /*ASL_LEVEL_NOTICE*/,
26-
FIRLoggerLevelInfo = 6 /*ASL_LEVEL_INFO*/,
27-
FIRLoggerLevelDebug = 7 /*ASL_LEVEL_DEBUG*/,
23+
/** Error level, matches ASL_LEVEL_ERR. */
24+
FIRLoggerLevelError = 3,
25+
/** Warning level, matches ASL_LEVEL_WARNING. */
26+
FIRLoggerLevelWarning = 4,
27+
/** Notice level, matches ASL_LEVEL_NOTICE. */
28+
FIRLoggerLevelNotice = 5,
29+
/** Info level, matches ASL_LEVEL_NOTICE. */
30+
FIRLoggerLevelInfo = 6,
31+
/** Debug level, matches ASL_LEVEL_DEBUG. */
32+
FIRLoggerLevelDebug = 7,
33+
/** Minimum log level. */
2834
FIRLoggerLevelMin = FIRLoggerLevelError,
35+
/** Maximum log level. */
2936
FIRLoggerLevelMax = FIRLoggerLevelDebug
3037
} FIR_SWIFT_NAME(FirebaseLoggerLevel);

Firebase/Database/Api/FIRDatabaseSwiftNameSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#import <Foundation/Foundation.h>
2020

2121
// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK.
22-
// // Wrap it in our own macro if it's a non-compatible SDK.
22+
// Wrap it in our own macro if it's a non-compatible SDK.
2323
#ifdef __IPHONE_9_3
2424
#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
2525
#else

Firebase/Messaging/FIRMMessageCode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) {
120120
kFIRMessagingMessageCodeRemoteNotificationsProxy000 = 12000, // I-FCM012000
121121
kFIRMessagingMessageCodeRemoteNotificationsProxy001 = 12001, // I-FCM012001
122122
kFIRMessagingMessageCodeRemoteNotificationsProxyAPNSFailed = 12002, // I-FCM012002
123+
kFIRMessagingMessageCodeRemoteNotificationsProxyMethodNotAdded = 12003, // I-FCM012003
123124
// FIRMessagingRmq2PersistentStore.m
124125
kFIRMessagingMessageCodeRmq2PersistentStore000 = 13000, // I-FCM013000
125126
kFIRMessagingMessageCodeRmq2PersistentStore001 = 13001, // I-FCM013001

Firebase/Messaging/FIRMessaging+FIRApp.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import "FIRAppInternal.h"
2020
#import "FIROptionsInternal.h"
2121

22-
#import "FIRMessagingConfig.h"
2322
#import "FIRMessagingConstants.h"
2423
#import "FIRMessagingLogger.h"
2524
#import "FIRMessagingPubSub.h"

Firebase/Messaging/FIRMessaging.m

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#import <UIKit/UIKit.h>
2525

2626
#import "FIRMessagingClient.h"
27-
#import "FIRMessagingConfig.h"
2827
#import "FIRMessagingConstants.h"
2928
#import "FIRMessagingContextManagerService.h"
3029
#import "FIRMessagingDataMessageManager.h"
@@ -133,7 +132,6 @@ @interface FIRMessaging ()
133132
// Due to our packaging requirements, we can't directly depend on FIRInstanceID currently.
134133
@property(nonatomic, readwrite, strong) FIRMessagingInstanceIDProxy *instanceIDProxy;
135134

136-
@property(nonatomic, readwrite, strong) FIRMessagingConfig *config;
137135
@property(nonatomic, readwrite, assign) BOOL isClientSetup;
138136

139137
@property(nonatomic, readwrite, strong) FIRMessagingClient *client;
@@ -157,18 +155,15 @@ + (FIRMessaging *)messaging {
157155
static FIRMessaging *messaging;
158156
static dispatch_once_t onceToken;
159157
dispatch_once(&onceToken, ^{
160-
// Start Messaging (Fully initialize in one place).
161-
FIRMessagingConfig *config = [FIRMessagingConfig defaultConfig];
162-
messaging = [[FIRMessaging alloc] initWithConfig:config];
158+
messaging = [[FIRMessaging alloc] initPrivately];
163159
[messaging start];
164160
});
165161
return messaging;
166162
}
167163

168-
- (instancetype)initWithConfig:(FIRMessagingConfig *)config {
164+
- (instancetype)initPrivately {
169165
self = [super init];
170166
if (self) {
171-
_config = config;
172167
_loggedMessageIDs = [NSMutableSet set];
173168
_instanceIDProxy = [[FIRMessagingInstanceIDProxy alloc] init];
174169
}
@@ -192,11 +187,9 @@ - (void)setRemoteMessageDelegate:(id<FIRMessagingDelegate>)delegate {
192187
#pragma mark - Config
193188

194189
- (void)start {
195-
_FIRMessagingDevAssert(self.config, @"Invalid nil config in FIRMessagingService");
196190

197191
[self saveLibraryVersion];
198-
[self setupLogger:self.config.logLevel];
199-
[self setupReceiverWithConfig:self.config];
192+
[self setupReceiver];
200193

201194
NSString *hostname = kFIRMessagingReachabilityHostname;
202195
self.reachability = [[FIRReachabilityChecker alloc] initWithReachabilityDelegate:self
@@ -259,18 +252,7 @@ - (void)saveLibraryVersion {
259252
currentLibraryVersion);
260253
}
261254

262-
- (void)setupLogger:(FIRMessagingLogLevel)loggerLevel {
263-
#if FIRMessaging_PROBER
264-
// do nothing
265-
#else
266-
FIRMessagingLogger *logger = FIRMessagingSharedLogger();
267-
FIRMessagingLogLevelFilter *filter =
268-
[[FIRMessagingLogLevelFilter alloc] initWithLevel:loggerLevel];
269-
[logger setFilter:filter];
270-
#endif
271-
}
272-
273-
- (void)setupReceiverWithConfig:(FIRMessagingConfig *)config {
255+
- (void)setupReceiver {
274256
self.receiver = [[FIRMessagingReceiver alloc] init];
275257
self.receiver.delegate = self;
276258
}

Firebase/Messaging/FIRMessagingLogger.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "FIRMessagingConfig.h"
1817
#import "FIRMMessageCode.h"
1918

2019
// The convenience macros are only defined if they haven't already been defined.
@@ -35,37 +34,8 @@
3534

3635
#endif // !defined(FIRMessagingLoggerInfo)
3736

38-
/// Protocols
39-
@protocol FIRMessagingLogFormatter <NSObject>
40-
- (NSString *)stringForFunc:(NSString *)func
41-
withFormat:(NSString *)fmt
42-
valist:(va_list)args
43-
level:(FIRMessagingLogLevel)level NS_FORMAT_FUNCTION(2, 0);
44-
@end
45-
46-
/// FIRMessagingLogWriter
47-
@protocol FIRMessagingLogWriter <NSObject>
48-
// Writes the given log message to where the log writer is configured to write.
49-
- (void)logMessage:(NSString *)msg level:(FIRMessagingLogLevel)level;
50-
@end
51-
52-
/// FIRMessagingLogFilter
53-
@protocol FIRMessagingLogFilter <NSObject>
54-
// Returns YES if |msg| at |level| should be logged; NO otherwise.
55-
- (BOOL)filterAllowsMessage:(NSString *)msg level:(FIRMessagingLogLevel)level;
56-
@end
57-
58-
@interface FIRMessagingLogLevelFilter : NSObject <FIRMessagingLogFilter>
59-
- (instancetype)initWithLevel:(FIRMessagingLogLevel)level;
60-
@end
61-
62-
6337
@interface FIRMessagingLogger : NSObject
6438

65-
@property(nonatomic, readwrite, strong) id<FIRMessagingLogFilter> filter;
66-
@property(nonatomic, readwrite, strong) id<FIRMessagingLogWriter> writer;
67-
@property(nonatomic, readwrite, strong) id<FIRMessagingLogFormatter> formatter;
68-
6939
- (void)logFuncDebug:(const char *)func
7040
messageCode:(FIRMessagingMessageCode)messageCode
7141
msg:(NSString *)fmt, ... NS_FORMAT_FUNCTION(3, 4);

0 commit comments

Comments
 (0)