Sending Notifications (Because That’s the Whole Point, Right?)
Oh, so you actually want to send notifications? Wow, what a revolutionary concept. Luckily for you, it’s so easy even a goldfish with Wi-Fi could do it. Let’s break it down.Before You Start: API Keys & Unique User IDs Matter!
First things first—do you have your API keys set up? No? Then what are you doing here? Notifications don’t send themselves. Check the Installation Guide before wasting any more of your precious time. Next, let’s talk user IDs. And I cannot stress this enough—they must be unique. If you think using “user1” for every single person is a genius idea, congratulations, you just created the world’s worst notification system. Use an email, a UUID, or literally anything that distinguishes one user from another. A random string? Sure, as long as it’s actually unique per user.Server (a.k.a. The Brains Behind It All)
Client (a.k.a. Where Users See The Magic)
Breakdown of sendify.sendNotifications() (Because Details Matter, Apparently)
- First argument (
userIds) – Who’s getting the notification? This must be an array. One user?["user123"]. Multiple users?["user1", "user2"]. Make sure these are unique! I will not repeat this again. Maybe on the next page. Who knows? - Second argument (
content) – The actual message. Keep it short and sweet. Nobody wants to read a novel in their notifications. - Third argument (
buttonText- optional) – If you want a button, this is the text. If not, then just pretend this argument doesn’t exist. - Fourth argument (
buttonUrl- optional) – Where does the button take users? Your app? A cat video? It’s up to you.