diff --git a/docs/FCM.rst b/docs/FCM.rst index 7944c255..ffc7d12d 100644 --- a/docs/FCM.rst +++ b/docs/FCM.rst @@ -18,7 +18,7 @@ Initialize the firebase admin in your ``settings.py`` file. .. code-block:: python # Import the firebase service - from firebase_admin import auth + import firebase_admin # Initialize the default app default_app = firebase_admin.initialize_app() diff --git a/push_notifications/models.py b/push_notifications/models.py index bc5055c1..876ce452 100644 --- a/push_notifications/models.py +++ b/push_notifications/models.py @@ -1,9 +1,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from firebase_admin import messaging from .fields import HexIntegerField -from .gcm import dict_to_fcm_message from .settings import PUSH_NOTIFICATIONS_SETTINGS as SETTINGS @@ -60,6 +58,9 @@ def get_queryset(self): class GCMDeviceQuerySet(models.query.QuerySet): def send_message(self, message, **kwargs): if self.exists(): + from firebase_admin import messaging + + from .gcm import dict_to_fcm_message from .gcm import send_message as fcm_send_message if not isinstance(message, messaging.Message): @@ -108,6 +109,9 @@ class Meta: verbose_name = _("FCM device") def send_message(self, message, **kwargs): + from firebase_admin import messaging + + from .gcm import dict_to_fcm_message from .gcm import send_message as fcm_send_message # GCM is not supported. @@ -137,7 +141,7 @@ def send_message(self, message, creds=None, **kwargs): if self.exists(): from .apns import apns_send_bulk_message - app_ids = self.filter(active=True).order_by("application_id")\ + app_ids = self.filter(active=True).order_by("application_id") \ .values_list("application_id", flat=True).distinct() res = [] for app_id in app_ids: