[messaging][ios] APNs token type is inferred from DEBUG instead of the signed APNs environment
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- firebase, ios, objective-c, react-native
- 領域
- mobile
調査の方向性
Start in packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m, where the APNs token type is selected from DEBUG. Read Firebase Messaging's supported unknown or autodetected APNs token behavior and determine how the signed aps-environment should drive the association. Done means Release builds signed for development no longer receive a production token type and FCM delivery succeeds.
索引モデルが issue の本文から書いたものです。
説明
Issue
On iOS, @react-native-firebase/messaging currently determines the APNs token type from the DEBUG compilation macro in RNFBMessaging+AppDelegate.m:
#ifdef DEBUG
[[FIRMessaging messaging] setAPNSToken:deviceToken
type:FIRMessagingAPNSTokenTypeSandbox];
#else
[[FIRMessaging messaging] setAPNSToken:deviceToken
type:FIRMessagingAPNSTokenTypeProd];
#endif
This assumes that:
DEBUG defined == APNs sandbox
DEBUG not defined == APNs production
However, the build configuration / DEBUG macro and the APNs environment of the signed application are independent.
A valid Release build can be signed using Apple Development provisioning and therefore have:
aps-environment = development
while DEBUG is not defined.
I reproduced this configuration on a physical iPhone.
Reproduction
Environment used for the runtime reproduction:
@react-native-firebase/messaging: 21.14.0
Firebase Messaging iOS SDK: 11.11.0
GoogleUtilities: 8.1.0
Xcode: 27.0
Device: iPhone 16e
iOS: 26.5
The application was:
Build configuration: Release
Signing: Apple Development
Signed aps-environment: development
DEBUG macro in RNFBMessaging: not defined
FirebaseAppDelegateProxyEnabled: not explicitly disabled
The signed application entitlement was verified from the built .app, rather than inferred from the Xcode build configuration.
With the standard RNFirebase AppDelegate integration, the RNFirebase callback therefore selected:
FIRMessagingAPNSTokenTypeProd
even though the signed application was using the APNs development environment.
After obtaining an FCM registration token, sending a real FCM notification resulted in:
HTTP 400
APNs error: BadDeviceToken
Control experiment
In an isolated diagnostic build I disabled the automatic proxy and explicitly associated the APNs token as sandbox as the initial association:
[[FIRMessaging messaging] setAPNSToken:deviceToken
type:FIRMessagingAPNSTokenTypeSandbox];
I then deleted the existing FCM registration token and generated a new one after the correct APNs association.
Using the same physical device and Firebase project, FCM delivery then succeeded.
Multiple subsequent real pushes were successfully delivered.
This was only a diagnostic control; I am not proposing that applications should manually force sandbox.
Why this appears to be incorrect
DEBUG describes how the code was compiled. It is not the authority for the APNs environment used by the signed application.
The APNs environment is determined by the application's signing/provisioning and resulting aps-environment entitlement.
For example, this is a valid combination:
Release configuration
DEBUG not defined
Apple Development signing
aps-environment = development
In that case the current RNFirebase heuristic selects Production while the APNs token belongs to Sandbox.
Conversely, relying on DEBUG could theoretically produce the opposite mismatch for a build where DEBUG is defined but the signed APNs environment is production.
Expected behavior
The APNs token type should not be inferred solely from DEBUG.
It should instead be determined from the actual APNs environment of the signed application, or RNFirebase could potentially allow Firebase Messaging to perform its supported APNs environment autodetection rather than explicitly forcing Sandbox/Prod from the compilation macro.
For example, Firebase Messaging supports an unknown/autodetected APNs token type, although I am not prescribing a specific implementation.
Current upstream source
I originally reproduced the issue with RNFirebase 21.14.0.
I also checked the current main branch and the AppDelegate callback still uses the same #ifdef DEBUG distinction:
I have not repeated the physical-device reproduction against the current main branch, so the runtime reproduction described above should be considered specific to 21.14.0; the current-source observation is source inspection only.
Impact
This does not appear to affect the usual combinations:
Debug + development signing
Release + App Store/TestFlight production signing
because the DEBUG heuristic happens to agree with the APNs environment in those cases.
It can affect valid configurations such as:
Release + development signing
which may be used for internal testing, QA, physical-device testing, or Release-mode builds that need to run without Metro.
In the reproduced case, the user-visible effect was complete FCM push delivery failure due to BadDeviceToken.
- 主要言語
- TypeScript
- スター
- 12.3k
- フォーク
- 2.3k
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
invertase/react-native-firebase のほかの issue
-
Needs Attention type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
invertase/react-native-firebase#9414 ·
メンテナーはふだん 1 日以内に返信
-
platform: android type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
invertase/react-native-firebase#9399 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[🐛] Firestore pipelines: Bytes and VectorValue constants are sent as their private fields対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンimpact: web-implementation platform: all plugin: firestore type: bug
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
invertase/react-native-firebase#9413 ·
メンテナーはふだん 1 日以内に返信
-
[🐛] Firestore pipelines: Timestamp (and Date) constants are sent as plain maps対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンimpact: web-implementation platform: all plugin: firestore type: bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
invertase/react-native-firebase#9412 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
invertase/react-native-firebase#9408 ·
メンテナーはふだん 1 日以内に返信
invertase/react-native-firebase の issue をすべて見る
似ている issue
-
area:desktop area:ui bug platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
anthropics/claude-code#106183 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
feature:App-Tour feature:Chat ready Web
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
digitalfabrik/integreat-app#4523 · リアクション 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Required Lexical field accepts two empty paragraphs対応中かも @lazerg が今日担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
payloadcms/payload#19222 ·
メンテナーはふだん 1 日以内に返信