This commit is contained in:
sankalp committed 2025-03-26 00:17:10 +05:45
1 parent b791a2992e
commit d4696b8fee
54 files changed
+1639 -5032

No files matched your search

+43 -5
View File
@@ -1,6 +1,44 @@
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from app.models import FCMDevice
from django.shortcuts import render
from django.http import JsonResponse, HttpResponse
# Create your views here.
# FireBase
def saveFCMToken(request, token):
try:
FCMDevice(token=token).save()
except:
pass
return JsonResponse({})
def showFirebaseJS(request):
data = """
importScripts('https://www.gstatic.com/firebasejs/11.0.2/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/11.0.2/firebase-messaging-compat.js');
firebase.initializeApp({
apiKey: "AIzaSyAVzOJh5v8_oZg4MoQkq0CzrAbeyHGn4z4",
authDomain: "institute-management-sys-a2d20.firebaseapp.com",
projectId: "institute-management-sys-a2d20",
storageBucket: "institute-management-sys-a2d20.firebasestorage.app",
messagingSenderId: "777235542100",
appId: "1:777235542100:web:4d0cb9553918cb3cc23dc1",
measurementId: "G-4QP9GYV0SJ"
});
const messaging = firebase.messaging();
messaging.onBackgroundMessage((payload) => {
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: payload.notification.icon
};
return self.registration.showNotification(notificationTitle, notificationOptions);
});
"""
return HttpResponse(data, content_type="text/javascript")