Как открыть URL при нажатии на push-уведомление с помощью firebase-admin в Python Django

Я собираюсь использовать python django's firebase-admin для отправки уведомления в FCM push notification, когда приложение находится в фоновом состоянии.

Когда пользователь нажимает на push-уведомление, приложение iOS/Android пытается открыть url уведомления. Как я должен передать это значение url?

  • noticeView.py:
from firebase_admin import credentials, messaging
import firebase_admin

class noticeCreateView(View):
    def post(self, request, *args, **kwargs):
        title = request.POST.get('title')
        content = request.POST.get('content')
        push = request.POST.get('push')

        if push:
            key = '....FCM Server Key...'
            
            cred = credentials.Certificate('./serviceAccountKey.json')
            default_app = None
            if '[DEFAULT]' not in firebase_admin._apps:
                default_app = firebase_admin.initialize_app(cred)
            else:
                default_app = firebase_admin._apps['[DEFAULT]']

            if default_app is not None:
                topic = 'notice'

                message = messaging.Message(
                    notification=messaging.Notification(
                        title=title,
                        body=sentence,
                    ),
                    apns=messaging.APNSConfig(
                        payload=messaging.APNSPayload(
                            aps=messaging.Aps(alert=messaging.ApsAlert(
                                title=title,
                                body=content,
                            )),
                        ),
                    ),
                    topic=topic
                )

                try:
                    response = messaging.send(message)
                    print(response)
                except Exception as e:
                    print('Push Fail', e)

            return HttpResponseRedirect(reverse('notice_list'))

Вернуться на верх