From 5bdbde79fd940b8fb51baa54bd1a1c11b3933eb6 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 30 Oct 2024 13:52:09 +0000 Subject: [PATCH] fix(messaging, ios): remove fake APNS token for simulator --- .../ios/Classes/FLTFirebaseMessagingPlugin.m | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 4a80cfd1a537..00c7400a3680 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -26,7 +26,6 @@ @implementation FLTFirebaseMessagingPlugin { NSObject *_registrar; NSData *_apnsToken; NSDictionary *_initialNotification; - bool simulatorToken; // Used to track if everything as been initialized before answering // to the initialNotification request @@ -57,7 +56,6 @@ - (instancetype)initWithFlutterMethodChannel:(FlutterMethodChannel *)channel _initialNotificationGathered = NO; _channel = channel; _registrar = registrar; - simulatorToken = false; // Application // Dart -> `getInitialNotification` // ObjC -> Initialize other delegates & observers @@ -1005,29 +1003,12 @@ + (NSDictionary *)remoteMessageUserInfoToDict:(NSDictionary *)userInfo { - (void)ensureAPNSTokenSetting { FIRMessaging *messaging = [FIRMessaging messaging]; - // With iOS SDK >= 10.4, an APNS token is required for getting/deleting token. We set a dummy - // token for the simulator for test environments. Historically, a simulator will not work for - // messaging. It will work if environment: iOS 16, running on macOS 13+ & silicon chip. We check - // the `_apnsToken` is nil. If it is, then the environment does not support and we set dummy - // token. -#if TARGET_IPHONE_SIMULATOR - if (simulatorToken == false && _apnsToken == nil) { - NSString *str = @"fake-apns-token-for-simulator"; - NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; - [[FIRMessaging messaging] setAPNSToken:data type:FIRMessagingAPNSTokenTypeSandbox]; - } - // We set this either way. We set dummy token once as `_apnsToken` could be nil next time - // which could possibly set dummy token unnecessarily - simulatorToken = true; -#endif - if (messaging.APNSToken == nil && _apnsToken != nil) { #ifdef DEBUG [[FIRMessaging messaging] setAPNSToken:_apnsToken type:FIRMessagingAPNSTokenTypeSandbox]; #else [[FIRMessaging messaging] setAPNSToken:_apnsToken type:FIRMessagingAPNSTokenTypeProd]; #endif - _apnsToken = nil; } }