diff options
author | Ryan Wilson <wilsonryan@google.com> | 2018-05-14 10:02:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-14 10:02:25 -0700 |
commit | 08f447cd3fffae80748239daada493fcc19c111f (patch) | |
tree | 52049deb6adda8eb87c07d01264bdc2e0be26ac5 /Firebase/Messaging | |
parent | 281d145dc93d310d1dc21fdff61e004faba3b057 (diff) |
Add global data collection switch. (#1219)
* Addition of global data collection switch.
* Added Messaging conformance to data switch.
Also formatted code.
* Move data collection flag internal until all SDKs conform to it.
* Formatting in response to code review.
Diffstat (limited to 'Firebase/Messaging')
-rw-r--r-- | Firebase/Messaging/FIRMessaging+FIRApp.m | 1 | ||||
-rw-r--r-- | Firebase/Messaging/FIRMessaging.m | 7 | ||||
-rw-r--r-- | Firebase/Messaging/FIRMessaging_Private.h | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/Firebase/Messaging/FIRMessaging+FIRApp.m b/Firebase/Messaging/FIRMessaging+FIRApp.m index 58ae3af..d48a3b4 100644 --- a/Firebase/Messaging/FIRMessaging+FIRApp.m +++ b/Firebase/Messaging/FIRMessaging+FIRApp.m @@ -72,6 +72,7 @@ } self.fcmSenderID = [options.GCMSenderID copy]; + self.globalAutomaticDataCollectionEnabled = [app isAutomaticDataCollectionEnabled]; // Swizzle remote-notification-related methods (app delegate and UNUserNotificationCenter) if ([FIRMessagingRemoteNotificationsProxy canSwizzleMethods]) { diff --git a/Firebase/Messaging/FIRMessaging.m b/Firebase/Messaging/FIRMessaging.m index 339bd7d..6222420 100644 --- a/Firebase/Messaging/FIRMessaging.m +++ b/Firebase/Messaging/FIRMessaging.m @@ -75,7 +75,7 @@ NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled = NSString *const kFIRMessagingAPNSTokenType = @"APNSTokenType"; // APNS Token type key stored in user info. -static NSString *const kFIRMessagingPlistAutoInitEnabled = +NSString *const kFIRMessagingPlistAutoInitEnabled = @"FirebaseMessagingAutoInitEnabled"; // Auto Init Enabled key stored in Info.plist @interface FIRMessagingMessageInfo () @@ -471,8 +471,9 @@ static NSString *const kFIRMessagingPlistAutoInitEnabled = if (isAutoInitEnabledObject) { return [isAutoInitEnabledObject boolValue]; } - // If none of above exists, we default assume FCM auto init is enabled. - return YES; + + // If none of above exists, we default to the global switch that comes from FIRApp. + return self.isGlobalAutomaticDataCollectionEnabled; } - (void)setAutoInitEnabled:(BOOL)autoInitEnabled { diff --git a/Firebase/Messaging/FIRMessaging_Private.h b/Firebase/Messaging/FIRMessaging_Private.h index 46daee0..6bac99d 100644 --- a/Firebase/Messaging/FIRMessaging_Private.h +++ b/Firebase/Messaging/FIRMessaging_Private.h @@ -25,6 +25,7 @@ typedef NS_ENUM(int8_t, FIRMessagingNetworkStatus) { kFIRMessagingReachabilityReachableViaWWAN, }; +FOUNDATION_EXPORT NSString *const kFIRMessagingPlistAutoInitEnabled; FOUNDATION_EXPORT NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled; @interface FIRMessagingRemoteMessage () @@ -37,6 +38,9 @@ FOUNDATION_EXPORT NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled; #pragma mark - Private API +// The data collection flag from Core. +@property(nonatomic, readwrite, getter=isGlobalAutomaticDataCollectionEnabled) BOOL globalAutomaticDataCollectionEnabled; + - (NSString *)defaultFcmToken; - (FIRMessagingClient *)client; - (FIRMessagingPubSub *)pubsub; |