Skip to content

Commit f228c3c

Browse files
Added custom sound notification & additional properties to notifications.
1 parent 0e65a90 commit f228c3c

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

utils/notifications.utils.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export const registerForPushNotificationsAsync = async () => {
1818
name: "default",
1919
importance: Notifications.AndroidImportance.MAX,
2020
vibrationPattern: [0, 250, 250, 250], // Optional: Add vibration
21-
sound: "default", // Enable sound
21+
sound: "notification", // Enable sound,
22+
lightColor: "#FF231F7C",
2223
});
2324
}
2425

@@ -61,7 +62,17 @@ export const handleNotification = async (
6162
title:
6263
remoteMessage.notification?.title ??
6364
NOTIFICATION_STRINGS.NEW_NOTIFICATION,
65+
subtitle: "Test subtitle",
6466
body: remoteMessage.notification?.body ?? "You received a new message",
67+
sound: "notification",
68+
badge: 1,
69+
vibrate: [0, 250, 250, 250], // Optional: Add vibration
70+
priority: Notifications.AndroidNotificationPriority.HIGH,
71+
color: "#FF231F7C",
72+
interruptionLevel: "critical",
73+
autoDismiss: false,
74+
sticky: true,
75+
categoryIdentifier: "new-message",
6576
},
6677
trigger: null,
6778
});
@@ -82,8 +93,18 @@ export const handleForegroundNotification = () => {
8293
await Notifications.scheduleNotificationAsync({
8394
content: {
8495
title: remoteMessage.notification?.title ?? "New Notification",
96+
subtitle: "Test subtitle",
8597
body: remoteMessage.notification?.body ?? "You received a new message",
86-
// You can include other fields like sound, badge, data, etc.
98+
data: { extraData: "Some data" },
99+
sound: "notification",
100+
badge: 1,
101+
vibrate: [0, 250, 250, 250], // Optional: Add vibration
102+
priority: Notifications.AndroidNotificationPriority.HIGH,
103+
color: "#FF231F7C",
104+
interruptionLevel: "critical",
105+
autoDismiss: false,
106+
sticky: true,
107+
categoryIdentifier: "new-message",
87108
},
88109
trigger: null, // null = show now (immediately)
89110
});
@@ -150,9 +171,18 @@ export async function triggerLocalSampleNotification() {
150171
await Notifications.scheduleNotificationAsync({
151172
content: {
152173
title: "Job Notification",
174+
subtitle: "Test subtitle",
153175
body: "This is a test notification.",
154-
sound: true,
176+
sound: "notification",
155177
data: { extraData: "Some data" },
178+
badge: 1,
179+
vibrate: [0, 250, 250, 250], // Optional: Add vibration
180+
priority: Notifications.AndroidNotificationPriority.HIGH,
181+
color: "#FF231F7C",
182+
interruptionLevel: "critical",
183+
autoDismiss: false,
184+
sticky: true,
185+
categoryIdentifier: "new-message",
156186
},
157187
trigger: null, // Send immediately
158188
});

0 commit comments

Comments
 (0)