Saurabh
Saurabh

Reputation: 449

How to enable the Google Firebase notification analytics in Django Python using PyFCM?

We are using the PyFCM module to send the notification via google firebase and somehow the notification analysis report's data is missing in the report section of the GCP firebase console.

Can someone know how to enable the notification analysis on firebase? As we want to know the details of the notification being sent, received, and opened.

Upvotes: 0

Views: 279

Answers (1)

Saurabh
Saurabh

Reputation: 449

We need to add the analytics_label with every notification being sent to firebase and for PyFcm using Django you can pass the analytics_label in the fcm_options given below:-

from pyfcm import FCMNotification

push_service = FCMNotification(api_key=FCM_SERVER_KEY)
registration_ids = ['user_mobile_token_key']
data = {
    "body": "test body,
    "title": "title,
    "priority": "high"
}

extra_kwargs = {'**fcm_options**': {
    'analytics_label': 'notification-label'}}
result = push_service.multiple_devices_data_message(registration_ids=registration_ids,
                                                                                 data_message=data, extra_kwargs=extra_kwargs)
print(result)

Upvotes: 2

Related Questions