aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Chen Liang <chliang@google.com>2018-04-13 16:45:09 -0700
committerGravatar GitHub <noreply@github.com>2018-04-13 16:45:09 -0700
commit6ebbdc7c66275d90da4958d98e1a077974ed0518 (patch)
treeb39837e0c82189189273505d43af0e2e7f4e34ec
parent4e01558661d74cb7eba3b6ba66d3ecc90720d5f6 (diff)
Remove didReceiveAPNSToken: triggered by IID deprecated method setAPNSToken: (#1094)
* remove a call that is triggered by IID, but no longer possible once we remove the deprecated method in IID
-rw-r--r--Firebase/Messaging/FIRMMessageCode.h2
-rw-r--r--Firebase/Messaging/FIRMessaging.m56
-rw-r--r--Firebase/Messaging/FIRMessaging_Private.h3
3 files changed, 10 insertions, 51 deletions
diff --git a/Firebase/Messaging/FIRMMessageCode.h b/Firebase/Messaging/FIRMMessageCode.h
index 1ec3a39..c1b8ffb 100644
--- a/Firebase/Messaging/FIRMMessageCode.h
+++ b/Firebase/Messaging/FIRMMessageCode.h
@@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) {
kFIRMessagingMessageCodeMessaging013 = 2013, // I-FCM002013
kFIRMessagingMessageCodeMessaging014 = 2014, // I-FCM002014
kFIRMessagingMessageCodeMessaging015 = 2015, // I-FCM002015
- kFIRMessagingMessageCodeMessaging016 = 2016, // I-FCM002016
+ kFIRMessagingMessageCodeMessaging016 = 2016, // I-FCM002016 - no longer used
kFIRMessagingMessageCodeMessaging017 = 2017, // I-FCM002017
kFIRMessagingMessageCodeMessaging018 = 2018, // I-FCM002018
kFIRMessagingMessageCodeRemoteMessageDelegateMethodNotImplemented = 2019, // I-FCM002019
diff --git a/Firebase/Messaging/FIRMessaging.m b/Firebase/Messaging/FIRMessaging.m
index 6111ceb..8fafab8 100644
--- a/Firebase/Messaging/FIRMessaging.m
+++ b/Firebase/Messaging/FIRMessaging.m
@@ -73,29 +73,11 @@ NSString * const FIRMessagingRegistrationTokenRefreshedNotification =
NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled =
@"com.firebase.messaging.auto-init.enabled"; // Auto Init Enabled key stored in NSUserDefaults
+NSString *const kFIRMessagingAPNSTokenType = @"APNSTokenType"; // APNS Token type key stored in user info.
+
static NSString *const kFIRMessagingPlistAutoInitEnabled =
@"FirebaseMessagingAutoInitEnabled"; // Auto Init Enabled key stored in Info.plist
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-/// A private helper to convert enum values without depending on their numerical values
-/// (avoid casting). This can be removed when InstanceID's deprecated APNS type enum is
-/// removed.
-FIRInstanceIDAPNSTokenType FIRIIDAPNSTokenTypeFromAPNSTokenType(FIRMessagingAPNSTokenType type) {
- switch (type) {
- case FIRMessagingAPNSTokenTypeProd:
- return FIRInstanceIDAPNSTokenTypeProd;
- case FIRMessagingAPNSTokenTypeSandbox:
- return FIRInstanceIDAPNSTokenTypeSandbox;
- case FIRMessagingAPNSTokenTypeUnknown:
- return FIRInstanceIDAPNSTokenTypeUnknown;
-
- default:
- return FIRInstanceIDAPNSTokenTypeUnknown;
- }
-}
-#pragma clang diagnostic pop
-
@interface FIRMessagingMessageInfo ()
@property(nonatomic, readwrite, assign) FIRMessagingMessageStatus status;
@@ -258,11 +240,6 @@ FIRInstanceIDAPNSTokenType FIRIIDAPNSTokenTypeFromAPNSTokenType(FIRMessagingAPNS
name:kFIRMessagingRegistrationTokenRefreshNotification
object:nil];
[center addObserver:self
- selector:@selector(didReceiveAPNSToken:)
- name:kFIRMessagingAPNSTokenNotification
- object:nil];
-
- [center addObserver:self
selector:@selector(applicationStateChanged)
name:UIApplicationDidBecomeActiveNotification
object:nil];
@@ -471,11 +448,13 @@ FIRInstanceIDAPNSTokenType FIRIIDAPNSTokenTypeFromAPNSTokenType(FIRMessagingAPNS
}
self.apnsTokenData = apnsToken;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- [self.instanceID setAPNSToken:apnsToken
- type:FIRIIDAPNSTokenTypeFromAPNSTokenType(type)];
-#pragma clang diagnostic pop
+ // Notify InstanceID that APNS Token has been set.
+ NSDictionary *userInfo = @{kFIRMessagingAPNSTokenType : @(type)};
+ NSNotification *notification =
+ [NSNotification notificationWithName:kFIRMessagingAPNSTokenNotification
+ object:[apnsToken copy]
+ userInfo:userInfo];
+ [[NSNotificationQueue defaultQueue] enqueueNotification:notification postingStyle:NSPostASAP];
}
#pragma mark - FCM
@@ -784,12 +763,6 @@ FIRInstanceIDAPNSTokenType FIRIIDAPNSTokenTypeFromAPNSTokenType(FIRMessagingAPNS
return [self currentLocale];
}
-- (void)setAPNSToken:(NSData *)apnsToken error:(NSError *)error {
- if (apnsToken) {
- self.apnsTokenData = [apnsToken copy];
- }
-}
-
#pragma mark - FIRMessagingReceiverDelegate
- (void)receiver:(FIRMessagingReceiver *)receiver
@@ -880,17 +853,6 @@ FIRInstanceIDAPNSTokenType FIRIIDAPNSTokenTypeFromAPNSTokenType(FIRMessagingAPNS
}
}
-- (void)didReceiveAPNSToken:(NSNotification *)notification {
- NSData *apnsToken = notification.object;
- if (![apnsToken isKindOfClass:[NSData class]]) {
- FIRMessagingLoggerDebug(kFIRMessagingMessageCodeMessaging016, @"Invalid APNS token type %@",
- NSStringFromClass([notification.object class]));
- return;
- }
- // Set this value directly, and since this came from InstanceID, don't set it back to InstanceID
- self.apnsTokenData = [apnsToken copy];
-}
-
#pragma mark - Application Support Directory
+ (BOOL)hasApplicationSupportSubDirectory:(NSString *)subDirectoryName {
diff --git a/Firebase/Messaging/FIRMessaging_Private.h b/Firebase/Messaging/FIRMessaging_Private.h
index 496fea4..46daee0 100644
--- a/Firebase/Messaging/FIRMessaging_Private.h
+++ b/Firebase/Messaging/FIRMessaging_Private.h
@@ -52,7 +52,4 @@ FOUNDATION_EXPORT NSString *const kFIRMessagingUserDefaultsKeyAutoInitEnabled;
- (BOOL)isNetworkAvailable;
- (FIRMessagingNetworkStatus)networkType;
-// Set the APNS token for FCM.
-- (void)setAPNSToken:(NSData *)apnsToken error:(NSError *)error;
-
@end