공식문서: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging?hl=ko
How I wrote
def send_push_topic(title, body, topic, post_id, push_id, url, badge_count):
apns_options = messaging.APNSConfig(
payload=messaging.APNSPayload(
aps=messaging.Aps(
alert=messaging.ApsAlert(title=title, body=body),
badge=badge_count, # Set the badge count here
# sound="default", # Set the notification sound
# category="<your-category>", # Optional: Set the notification category
),
),
)
# Define Android-specific parameters
android_config = messaging.AndroidConfig(
notification=messaging.AndroidNotification(
title=title,
body=body,
icon='ico_noti', # depands on ur choice
color='#2c6ceb', # depands on ur choice
# notification_count=badge_count,
# click_action="<your-action>", # Optional: Set the action when the notification is clicked
),
priority="high", # Set the priority of the notification
)
message = messaging.Message(
apns=apns_options,
android=android_config,
data={'title': title, 'text': body, 'post_id': post_id, 'push_id': push_id, 'url': url, 'badge': "1"},
topic=topic, # eg) "'stock-GOOG' in topics || 'industry-tech' in topics"
)
res = messaging.send(message)
print('Successfully sent message:', res)