HomeiOS DevelopmentPoints with FCM Notification Hyperlink Redirection and Picture Show on iOS (PWA),...

Points with FCM Notification Hyperlink Redirection and Picture Show on iOS (PWA), and Duplicate Notifications


I am utilizing Firebase Cloud Messaging (FCM) to ship push notifications to Android, Internet, and iOS gadgets, together with a PWA on iOS. My implementation in Python efficiently sends notifications with a hyperlink, and it really works as meant on Android and Internet. Nonetheless, I am encountering some points particular to iOS:

Hyperlink Redirection on iOS: Notifications acquired on iOS gadgets (particularly inside a PWA) do not redirect to the supplied URL upon clicking. The identical setup works for Android and Internet. How can I allow URL redirection for iOS?

Picture Show in Notifications on iOS: My notifications embrace a picture, which is displayed in Android and Internet notifications. Nonetheless, I am undecided if iOS helps picture show in FCM notifications, particularly inside a PWA context. Can iOS show photos in notifications despatched by way of FCM?

Duplicate Notifications: Whatever the platform, I am receiving every notification twice. Is there one thing in my implementation inflicting this habits? and my Entrance-end is subsequent.js

Here is the related a 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, physique, icon, picture, url):
    # [Code omitted for brevity]

    strive:
        message = messaging.Message(
            # [Notification setup for all platforms]
            # Android-specific configuration
            android=AndroidConfig(
                notification=AndroidNotification(
                    icon=icon,
                    colour="#f45342",
                    click_action=url
                )
            ),
            # iOS-specific configuration
            apns=APNSConfig(
                payload=APNSPayload(
                    aps=Aps(
                        badge=42,
                        class=url
                    )
                )
            ),
            # Internet-specific configuration
            webpush=WebpushConfig(
                fcm_options=WebpushFCMOptions(hyperlink=url)
            ),
            token=registration_token,
        )

        response = messaging.ship(message)
        return response
    besides Exception as e:
        return str(e)

Any insights or strategies for these iOS-specific points and the duplicate notifications drawback can be enormously appreciated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments