From 3e72bfa56c860826429a842f6c128d78d4a930db Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 1 Jun 2017 19:47:08 -0400 Subject: react-native-web port of fmf app --- client/src/lib/components/pushNotifications.js | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 client/src/lib/components/pushNotifications.js (limited to 'client/src/lib/components/pushNotifications.js') diff --git a/client/src/lib/components/pushNotifications.js b/client/src/lib/components/pushNotifications.js new file mode 100644 index 0000000..832f45b --- /dev/null +++ b/client/src/lib/components/pushNotifications.js @@ -0,0 +1,38 @@ +import PushNotification from 'react-native-push-notification' + +function init(cb) { + PushNotification.configure({ + onRegister: (token) => { + fetch("https://hanselgretelarmory.com/_services/push/add", { + method: "POST", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + registrationId: token.token, + channel: 'feed', + platform: token.os, + }), + }).then(() => { + // console.warn('pushed token') + }).catch((err) => { + // console.warn('got error') + }) + }, + onNotification: (notification) => { + cb(notification) + }, + permissions: { + alert: true, + badge: false, + sound: false + }, + popInitialNotification: true, + requestPermissions: true, + }) +} + +export default { + init: init, +} -- cgit v1.2.3-70-g09d2