This file contains 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> | |
<head> | |
<title>Notification Center</title> | |
<style> | |
body { | |
text-align: center; | |
} | |
h1 { |
This file contains 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
app.post('/notify', (req, res) => { | |
let msg = req.body.message, | |
title = req.body.title, | |
type = req.body.type, | |
topic = req.body.topic | |
if (type === 'topic') { | |
sendToTopics(msg, title, topic, res) | |
} else { |
This file contains 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 sendToAll = (msg, title, regIdArray, response) => { | |
const data = { | |
"data": { | |
"body": msg, | |
"title": title | |
} | |
} | |
const folds = regIdArray.length % 1000 |
This file contains 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 sendToTopics = (msg, title, topic, response) => { | |
const data = { | |
"data": { | |
"body": msg, | |
"title": title | |
} | |
} | |
data['to'] = '/topics/' + topic |
This file contains 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 sendNotifications = (data) => { | |
const dataString = JSON.stringify(data) | |
const headers = { | |
'Authorization': 'key=<your firebase legacy server key>', | |
'Content-Type': 'application/json', | |
'Content-Length': dataString.length | |
} |
This file contains 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
app.get('/notifications', (req, res) => { | |
res.sendFile(__dirname + '/notifcenter.html') | |
}) | |
app.post('/store', (req, res) => { | |
MongoClient.connect(url, (err, db) => { | |
if (err) throw err | |
else { | |
db.collection('tokens').insertOne(req.body, (err, body) => { |
This file contains 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
'use strict' | |
const app = require('express')(), | |
request = require('request'), | |
mongo = require('mongodb'), | |
bodyParser = require('body-parser') | |
app.use(bodyParser.json()) | |
app.use(bodyParser.urlencoded({ | |
extended: false |
This file contains 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
var app = angular.module('home', []); | |
app.directive('richcard', ['$sce', '$filter', function ($sce, $filter) { | |
return { | |
restrict: 'EA', | |
link: function (scope, element) { | |
scope.$watch('ld', function (val) { | |
var val = $sce.trustAsHtml($filter('json')(val)); | |
element[0].outerHTML = '<script type="application/ld+json">'+ val + '</script>' | |
}); |
This file contains 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
app.controller('homeController', ['$scope', function ($scope) { | |
$scope.$root.ld = { | |
"@context": "http://schema.org/", | |
"@type": "WebSite", | |
"name": 'My Wonderful Site', | |
"image": "https://mywonderfulsite.com/logo.png", | |
"description": 'We have the best content in the world', | |
"url": 'https://mywonderfulsite.com/' | |
} |
This file contains 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
/* visit www.apple.com and look at | |
the source code to find it. | |
*/ | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@id": "https://www.apple.com/#organization", | |
"@type": "Organization", | |
"name": "Apple", |
NewerOlder