This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://github.com/benixal | |
https://www.youtube.com/@benixal | |
*/ | |
export default { | |
// @ts-ignore | |
async fetch(request, env, ctx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>WebSocket Simple Chat</title> | |
<style> | |
#chatbox { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener("push", (event) => { | |
const notif = event.data.json().notification; | |
event.waitUntil(self.registration.showNotification(notif.title, { | |
body: notif.body, | |
icon: notif.image, /* or "icon.png" */ | |
data: { | |
url: notif.click_action | |
} | |
})) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$authorizationHeader = "Authorization: Bearer <YOUR_ACCESS_TOKEN>"; | |
/* | |
Steps to get Authentication Bearer : | |
1.Got to Google OAuth Playground: https://developers.google.com/oauthplayground | |
2.In the "Input your own scopes" for FCM use this url: https://www.googleapis.com/auth/firebase.messaging | |
3.Tap Authorize API. | |
4.Pick correct user for authorisation and allow access. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// full project with vue: https://github.com/benixal/vue-firebase-push-notification | |
var admin = require("firebase-admin"); | |
var serviceAccount = require("./your-private-key.json"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount) | |
}); | |
// This registration token comes from the client FCM SDKs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
var fs = require('fs'); | |
const port = 8060; | |
var db = "database"; | |
if (!fs.existsSync(db)) { | |
fs.mkdirSync(db); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rules_version = '2'; | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
match /chats/{userId}/{document=**} { | |
allow read, write: if | |
( | |
userId == request.auth.uid | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const port = 8089; | |
http.createServer((req, res) => { | |
const headers = { | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Methods': '*', | |
'Access-Control-Request-Method': '*', | |
'Access-Control-Allow-Headers': '*', |