I’m using Firebase Cloud Messaging (FCM) to send push notifications to Android, Web, and iOS devices, including a PWA on iOS. My implementation in Python successfully sends notifications with a link, and it works as intended on Android and Web. However, I’m encountering some issues specific to iOS:
Link Redirection on iOS: Notifications received on iOS devices (especially within a PWA) don’t redirect to the provided URL upon clicking. The same setup works for Android and Web. How can I enable URL redirection for iOS?
Image Display in Notifications on iOS: My notifications include an image, which is displayed in Android and Web notifications. However, I’m not sure if iOS supports image display in FCM notifications, especially within a PWA context. Can iOS display images in notifications sent via FCM?
Duplicate Notifications: Regardless of the platform, I’m receiving each notification twice. Is there something in my implementation causing this behavior? and my Front-end is next.js
Here’s the relevant part of my Python code for sending notifications
from firebase_admin import messaging
from firebase_admin.messaging import WebpushConfig, WebpushFCMOptions, AndroidConfig, AndroidNotification, APNSConfig, APNSPayload, Aps
def send_to_firebase_cloud_messaging(token, title, body, icon, image, url):
# [Code omitted for brevity]
try:
message = messaging.Message(
# [Notification setup for all platforms]
# Android-specific configuration
android=AndroidConfig(
notification=AndroidNotification(
icon=icon,
color="#f45342",
click_action=url
)
),
# iOS-specific configuration
apns=APNSConfig(
payload=APNSPayload(
aps=Aps(
badge=42,
category=url
)
)
),
# Web-specific configuration
webpush=WebpushConfig(
fcm_options=WebpushFCMOptions(link=url)
),
token=registration_token,
)
response = messaging.send(message)
return response
except Exception as e:
return str(e)
Any insights or suggestions for these iOS-specific issues and the duplicate notifications problem would be greatly appreciated.




