diff options
| author | jules <jules@carbonpictures.com> | 2017-06-02 15:42:34 +0000 |
|---|---|---|
| committer | jules <jules@carbonpictures.com> | 2017-06-02 15:42:34 +0000 |
| commit | 5f26431f03228a85273e7f7d51abd6098ea9f2a5 (patch) | |
| tree | 6a709972cbb0babd68aaa10fe277b2c843fd7451 /client/src/lib/components/pushNotifications.js | |
| parent | 291fe3eedd9a460fc44d2ea3ea81c7d79f2dfbcf (diff) | |
| parent | dd70fa81a205304cb48bbc0494ad34c16d496ff2 (diff) | |
merge
Diffstat (limited to 'client/src/lib/components/pushNotifications.js')
| -rw-r--r-- | client/src/lib/components/pushNotifications.js | 38 |
1 files changed, 38 insertions, 0 deletions
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, +} |
