PATH:
home
/
rwabteecom
/
project_11
/
resources
/
views
/
dashboard
/
layouts
/
Editing: firebase.blade.php
@auth() <script src="{{ asset('backend/firebase/firebase-app.js') }}"></script> <script src="{{ asset('backend/firebase/firebase-messaging.js') }}"></script> <script> navigator.serviceWorker.register("{{ asset('firebase-messaging-sw.js') }}"); </script> <script type="text/javascript"> var firebaseConfig = { apiKey: "{{ gs('firebase_api_key') }}", authDomain: "{{ gs('firebase_auth_domain') }}", databaseURL: "{{ gs('firebase_database_url') }}", projectId: "{{ gs('firebase_project_id') }}", storageBucket: "{{ gs('firebase_storage_bucket') }}", messagingSenderId: "{{ gs('firebase_messaging_sender_id') }}", appId: "{{ gs('firebase_app_id') }}" }; // firebase.initializeApp(firebaseConfig); firebase.initializeApp(firebaseConfig); const messaging = firebase.messaging(); function IntitalizeFireBaseMessaging() { messaging .requestPermission() .then(function() { return messaging.getToken(); }) .then(function(token) { $.ajax({ url: '{{ route("dashboard.settings.update.device-token") }}', method: "POST", // processData: false, // contentType: false, data: { device_token:token, _token:"{{ csrf_token() }}" }, success: function(response) { console.log(response) }, error: function(response) { console.log(response) } }); var els = document.getElementsByClassName("device_token_front"); for (var i = 0; i < els.length; i++) { els[i].value = token; } }) .catch(function(reason) { console.log(reason); }); } messaging.onMessage(function(payload) { const notificationOption = { body: payload.notification.body, icon: payload.notification.icon }; if (Notification.permission === "granted") { var notification = new Notification(payload.notification.title, notificationOption); notification.onclick = function(ev) { ev.preventDefault(); window.open(payload.notification.click_action, '_blank'); notification.close(); } } }); messaging.onTokenRefresh(function() { messaging.getToken() .then(function(newtoken) { }) .catch(function(reason) { console.log(reason); }) }) IntitalizeFireBaseMessaging(); </script> @endauth
SAVE
CANCEL