Skip to content

Commit 53f9ad8

Browse files
Dean SoferDean Sofer
authored andcommitted
Add player name to notification
1 parent 101cf60 commit 53f9ad8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

functions/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@ exports.sendMoveNotification = onValueCreated('/moves/{moveId}', async event =>
2929
return null;
3030
}
3131

32+
// Query the player's name from the database
33+
let playerName = move.player;
34+
if (move.player) {
35+
const playerNameSnapshot = await db.ref(`/users/${move.player}/name`).once('value');
36+
if (playerNameSnapshot.exists()) {
37+
playerName = playerNameSnapshot.val();
38+
}
39+
}
40+
3241
const payload = {
3342
token: recipientToken,
3443
notification: {
35-
title: `It's your turn!`,
44+
title: `${playerName} made a move`,
3645
body: move.move
3746
},
3847
data: {

0 commit comments

Comments
 (0)