Skip to content

Instantly share code, notes, and snippets.

@hyperh
hyperh / react-native-push-notification.js
Last active May 20, 2016 06:32
Setting up react-native-push-notification
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}`); }
});
@hyperh
hyperh / sendAPN.js
Last active May 20, 2016 06:48
Sending an APN from Meteor server
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);
@hyperh
hyperh / apnagent.js
Created May 20, 2016 05:57
apnagent setup
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) {