Skip to content

Commit 6be0af4

Browse files
committed
server-side-notifications
1 parent 15fcbf2 commit 6be0af4

13 files changed

+2216
-6
lines changed

awesome-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"expo": "^31.0.2",
13+
"graphql-request": "^1.8.2",
1314
"react": "16.5.0",
1415
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
1516
"react-navigation": "^3.0.0"

awesome-app/screens/Notification.js

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Platform
88
} from "react-native";
99
import { Notifications, Permissions } from "expo";
10+
import { request } from "graphql-request";
1011

1112
export default class Notification extends Component {
1213
registerForPushNotification = async () => {
@@ -52,6 +53,17 @@ export default class Notification extends Component {
5253
badge: true
5354
});
5455
}
56+
let mutation = `
57+
mutation createNotificationToken($token: String!){
58+
createNotificationToken(token: $token) {
59+
id
60+
}
61+
}
62+
`;
63+
const variables = {
64+
token
65+
};
66+
await request("http://192.168.1.7:4000", mutation, variables);
5567
await AsyncStorage.setItem("notificationStatus", "true");
5668
}
5769
this.goToHome();

awesome-app/yarn.lock

+26-6
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,14 @@ create-react-context@^0.2.3:
18091809
fbjs "^0.8.0"
18101810
gud "^1.0.0"
18111811

1812+
1813+
version "2.2.2"
1814+
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723"
1815+
integrity sha1-pH/09/xxLauo9qaVoRyUhEDUVyM=
1816+
dependencies:
1817+
node-fetch "2.1.2"
1818+
whatwg-fetch "2.0.4"
1819+
18121820
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
18131821
version "5.1.0"
18141822
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -2674,6 +2682,13 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6,
26742682
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
26752683
integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==
26762684

2685+
graphql-request@^1.8.2:
2686+
version "1.8.2"
2687+
resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.8.2.tgz#398d10ae15c585676741bde3fc01d5ca948f8fbe"
2688+
integrity sha512-dDX2M+VMsxXFCmUX0Vo0TopIZIX4ggzOtiCsThgtrKR4niiaagsGTDIHj3fsOMFETpa064vzovI+4YV4QnMbcg==
2689+
dependencies:
2690+
cross-fetch "2.2.2"
2691+
26772692
growly@^1.3.0:
26782693
version "1.3.0"
26792694
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
@@ -3795,6 +3810,11 @@ [email protected]:
37953810
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
37963811
integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=
37973812

3813+
3814+
version "2.1.2"
3815+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
3816+
integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=
3817+
37983818
node-fetch@^1.0.1:
37993819
version "1.7.3"
38003820
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
@@ -4332,7 +4352,7 @@ [email protected], react-native-gesture-handler@^1.0.0:
43324352
invariant "^2.2.2"
43334353
prop-types "^15.5.10"
43344354

4335-
"react-native-maps@github:expo/react-native-maps#v0.22.1-exp.0":
4355+
react-native-maps@expo/react-native-maps#v0.22.1-exp.0:
43364356
version "0.22.1"
43374357
resolved "https://codeload.github.com/expo/react-native-maps/tar.gz/e6f98ff7272e5d0a7fe974a41f28593af2d77bb2"
43384358

@@ -5353,16 +5373,16 @@ watch@~0.18.0:
53535373
exec-sh "^0.2.0"
53545374
minimist "^1.2.0"
53555375

5376+
[email protected], whatwg-fetch@^2.0.4:
5377+
version "2.0.4"
5378+
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
5379+
integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==
5380+
53565381
whatwg-fetch@>=0.10.0:
53575382
version "3.0.0"
53585383
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
53595384
integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==
53605385

5361-
whatwg-fetch@^2.0.4:
5362-
version "2.0.4"
5363-
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
5364-
integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==
5365-
53665386
which-module@^2.0.0:
53675387
version "2.0.0"
53685388
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"

server/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/**/*

server/datamodel.prisma

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type pushNotifications {
2+
id: ID! @unique
3+
token: String! @unique
4+
platform: String
5+
timezoneOffset: Int
6+
receiveNotifications: Boolean! @default(value: "true")
7+
}

0 commit comments

Comments
 (0)