@@ -180,6 +180,14 @@ - (void)tokenWithAuthorizedEntity:(NSString *)authorizedEntity
180
180
[tokenOptions addEntriesFromDictionary: options];
181
181
}
182
182
183
+ #if TARGET_OS_SIMULATOR && TARGET_OS_IOS
184
+ if (tokenOptions[kFIRMessagingTokenOptionsAPNSKey ] != nil ) {
185
+ // If APNS token is available on iOS Simulator, we must use the sandbox profile
186
+ // https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes
187
+ tokenOptions[kFIRMessagingTokenOptionsAPNSIsSandboxKey ] = @(YES );
188
+ }
189
+ #endif
190
+
183
191
if (tokenOptions[kFIRMessagingTokenOptionsAPNSKey ] != nil &&
184
192
tokenOptions[kFIRMessagingTokenOptionsAPNSIsSandboxKey ] == nil ) {
185
193
// APNS key was given, but server type is missing. Supply the server type with automatic
@@ -634,7 +642,6 @@ - (void)setAPNSToken:(NSData *)APNSToken withUserInfo:(NSDictionary *)userInfo {
634
642
}
635
643
return ;
636
644
}
637
- NSInteger type = [userInfo[kFIRMessagingAPNSTokenType ] integerValue ];
638
645
639
646
// The APNS token is being added, or has changed (rare)
640
647
if ([self .currentAPNSInfo.deviceToken isEqualToData: APNSToken]) {
@@ -643,10 +650,17 @@ - (void)setAPNSToken:(NSData *)APNSToken withUserInfo:(NSDictionary *)userInfo {
643
650
return ;
644
651
}
645
652
// Use this token type for when we have to automatically fetch tokens in the future
653
+ #if TARGET_OS_SIMULATOR && TARGET_OS_IOS
654
+ // If APNS token is available on iOS Simulator, we must use the sandbox profile
655
+ // https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes
656
+ BOOL isSandboxApp = YES ;
657
+ #else
658
+ NSInteger type = [userInfo[kFIRMessagingAPNSTokenType ] integerValue ];
646
659
BOOL isSandboxApp = (type == FIRMessagingAPNSTokenTypeSandbox);
647
660
if (type == FIRMessagingAPNSTokenTypeUnknown) {
648
661
isSandboxApp = FIRMessagingIsSandboxApp ();
649
662
}
663
+ #endif
650
664
651
665
// Pro-actively invalidate the default token, if the APNs change makes it
652
666
// invalid. Previously, we invalidated just before fetching the token.
0 commit comments