firebase-admin-python icon indicating copy to clipboard operation
firebase-admin-python copied to clipboard

Fix Aps incorrect Doc String

Open davit555 opened this issue 7 months ago • 1 comments

class Aps:
    """Aps dictionary to be included in an APNS payload.

    Args:
        alert: A string or a ``messaging.ApsAlert`` instance (optional).
        badge: A number representing the badge to be displayed with the message (optional).
        sound: Name of the sound file to be played with the message or a
            ``messaging.CriticalSound`` instance (optional).
        content_available: A boolean indicating whether to configure a background update
            notification (optional).
        category: String identifier representing the message type (optional).
        thread_id: An app-specific string identifier for grouping messages (optional).
        mutable_content: A boolean indicating whether to support mutating notifications at
            the client using app extensions (optional).
        custom_data: A dict of custom key-value pairs to be included in the Aps dictionary
            (optional).
    """

    def __init__(self, alert=None, badge=None, sound=None, content_available=None, category=None,
                 thread_id=None, mutable_content=None, custom_data=None):
        self.alert = alert
        self.badge = badge
        self.sound = sound
        self.content_available = content_available
        self.category = category
        self.thread_id = thread_id
        self.mutable_content = mutable_content
        self.custom_data = custom_data

in the doc strings Aps content_available states as boolean property, while in reality we need to send a number either 0 or 1.

Please fix the doc string, we where struggiling to understand why the custom data didn't receive in the message payload because of that incorrect stated doc string. Than you

davit555 avatar Apr 16 '25 12:04 davit555

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Apr 16 '25 12:04 google-oss-bot

The doc string here is correct. While the Aps payload content-available property is a number (1 or 0), in the SDK we accept a boolean and internally map that boolean to the correct digital 1 or 0. https://github.com/firebase/firebase-admin-python/blob/363166bbfdbf72945ace00296c93b7c37773e092/firebase_admin/_messaging_encoder.py#L578-L579

If this is not being represented in the sent payload, please create a new issue with a code snippet to reproduce this.

jonathanedey avatar Jun 26 '25 15:06 jonathanedey