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
import apnagent from 'apnagent'; | |
let agent = new apnagent.Agent(); | |
agent | |
.set('cert', Assets.getText('cert.pem')) | |
.set('key', Assets.getText('key.pem')) | |
.enable('sandbox') | |
.connect(function (err) { | |
if (err) { |
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
import _ from 'lodash'; | |
const SEND_APN_MSG = 'notifications.send.APNMsg'; | |
Meteor.methods({ | |
'notifications.send.APNMsg'({sendToUserId}) { | |
check(arguments[0], { | |
sendToUserId: String, | |
}); | |
const user = Meteor.users.findOne(sendToUserId); |
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
import React from 'react-native'; | |
import PushNotification from 'react-native-push-notification'; | |
export default function () { | |
PushNotification.configure({ | |
// (optional) Called when Token is generated (iOS and Android) | |
onRegister(data) { | |
Meteor.call('notifications.set.pushToken', {data}, err => { | |
if (err) { alert(`notifications.set.pushToken: ${err.reason}`); } | |
}); |
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 SET_PUSH_TOKEN = 'notifications.set.pushToken'; | |
Meteor.methods({ | |
'notifications.set.pushToken'({token, os}) { | |
check(arguments[0], { | |
token: String, | |
os: String, | |
}); | |
const userId = this.userId; | |
if (!userId) { |
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
{ | |
"presets": [ | |
"es2015", | |
"react", | |
"stage-0" | |
] | |
} |
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
import React, { Component } from 'react'; | |
export default class App extends Component { | |
render() { | |
return ( | |
<div> | |
Hello world! | |
</div> | |
); | |
} |
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
export default ({ body, title }) => { | |
return ` | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>${title}</title> | |
</head> | |
<body> | |
<div id="root">${body}</div> |
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
import express from 'express'; | |
import React from 'react'; | |
import { renderToString } from 'react-dom/server'; | |
import App from '../app/components/App'; | |
import template from '../app/template'; | |
const app = express(); | |
app.get('/', (req, res) => { | |
const appString = renderToString(<App />); |
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 path = require('path'); | |
const nodeExternals = require('webpack-node-externals'); | |
module.exports = { | |
name: 'SSR', | |
entry: './app/SSR.js', | |
output: { | |
path: path.join(__dirname, '.', 'dist', 'assets'), | |
filename: 'SSR.js', | |
libraryTarget: 'commonjs2', |
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
import React from 'react'; | |
import { renderToString } from 'react-dom/server'; | |
import template from './template'; | |
import App from './components/App'; | |
export default function render(req, res) { | |
const appString = renderToString(<App />); | |
res.send(template({ | |
body: appString, | |
title: 'FROM THE SERVER', |
OlderNewer