Add set_auto_init_enabled() to Firebase Messaging (Android + iOS) - #45
Open
BlackwindITA wants to merge 1 commit into
Open
Add set_auto_init_enabled() to Firebase Messaging (Android + iOS)#45BlackwindITA wants to merge 1 commit into
BlackwindITA wants to merge 1 commit into
Conversation
Firebase generates an FCM registration token on first launch. Apps that must not collect a device identifier before the user consents can turn that off in the manifest (Android) or Info.plist (iOS), but there is currently no way to turn it back on from GDScript -- so the token is never created and push silently never arrives. Adds set_auto_init_enabled(bool) and is_auto_init_enabled() to both platforms, plus the matching README entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Firebase generates an FCM registration token on first launch. An app that must not collect a device identifier before the user has consented can turn that off declaratively:
<meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" />FirebaseMessagingAutoInitEnabled = falseinInfo.plistBut once it is off there is currently no way to turn it back on from GDScript. The plugin exposes
initialize,request_permission,get_token,get_apns_token,subscribe_to_topicandunsubscribe_from_topic, and none of them touches auto-init — so the token is never created and push silently never arrives.This matters beyond convenience: with auto-init left on, Google Play's Data Safety form has to declare the collection as "Required" rather than optional, and a privacy policy cannot name consent as the legal basis.
The change
Adds two methods to Firebase Messaging on both platforms, plus the matching README entries:
set_auto_init_enabled(enabled: bool)is_auto_init_enabled() -> boolAndroid uses
FirebaseMessaging.getInstance().isAutoInitEnabled, iOS uses[FIRMessaging messaging].autoInitEnabled. Both follow the error handling already used by the surrounding methods (Android emitsmessaging_error, iOS logs).Usage:
What I verified, and what I did not
Not verified: I did not build the AAR or the xcframework, so these changes have not been compiled inside this project's build system. They are small and follow the existing patterns, but they deserve a build before merging.
Verified: the underlying platform API is exactly what a shipped app needs. I hit this gap in a Godot 4.7 game that uses this plugin, and worked around it with a ~30-line local GodotPlugin that does nothing but call
setAutoInitEnabled. With auto-init disabled in the manifest and that call made only after the player accepts, the chain works end to end on an Android 10 device:FirebaseInitProvider initialization successful→Subscribed to topic→ notification delivered with the app closed. This PR is that workaround, moved to where it belongs.Happy to adjust naming or split the platforms if you prefer.