And That Reminds Me…

Chloe Verity
Songkick
Published in
4 min readJul 5, 2019

--

Imagine this: those tickets, the ones you simply can’t live without, are going on sale soon, and you absolutely MUST have them. What’s been your go-to plan for being first in line? Setting 15 alarms for when Glasto tickets go on sale at 9 in the morning? Relying on your body clock to know exactly when to log on and buy those Biebs tix? Or maybe you’re waiting to simply *feel* the presence of Beyoncé’s ethereal, all-powerful spirit, and then you’ll just know?

At Songkick, we’re always trying to make sure that we’ve got your back. With a mantra like “Never miss another concert”, we have to ensure that our users have the best possible access to their favourite concert tickets. That’s why, in our latest iOS release, we’ve made it that much easier for you to be quickest to the punch.

Introducing: Notification Reminders!

Now, you can decide not only to add an event’s ticket release time to your calendar, but you can also set up reminders that come in the form of push notifications, both of which go off a cool 10 minutes before they go on sale (no more sweating, looking for your phone charger while those T-Swift tickets fly off the e-shelves). And hey, in the event you suddenly fall out of love with her, you can cancel that reminder too — careful though, she might write a song about it.

Behind the scenes, this first means making use of additional info that we receive from our ticket vendors (where it’s available). Before, while we would receive the ticket onsale time, we wouldn’t use it (only the date). Now we pass both the date and time through the ticket’s API endpoint, as an ISO8601DateTime. We do this for not only an accurate time, but also so we can account for timezones — so whether you’re in Taiwan or Timbuktu, you’ll get your Tay Tay tickets.

User flow for onsale reminders

The blue “Notify me” button that appears on each event page (that has an onsale date & time) is tied to this ISO8601DateTime, which means the button stays live until 10 minutes before (the reminder is sent 10 minutes before the tickets go on sale).

The logic behind the local notification seemed daunting at first;

Timezones! Status Alerts! Permissions! Dispatch Queues! Panic! At the Disco!

We started by separating the tasks into smaller, actionable sizes — the first of which was creating an action sheet, with the option to set a reminder, or add the event to your calendar. This was easy enough; you simply create the buttons with their respective titles and styles, along with the function they should perform, then add them to your action sheet.

Now onto the function itself. First, I’ll take you through setting up a local notification.

Before anything, we have to check that the user has push notification permissions enabled. If the user has no permissions set up, they receive the initial alert. Then, on the main thread, it will try to perform the function again, but they will inevitably now have them either enabled or disabled. If they have them disabled, they will be encouraged to go to settings to change them, but if they’re enabled, then we’ve made it over the first hurdle.

To schedule the notification itself, we use Xcode’s built in UNMutableNotificationContent(), and DateComponents. The DateComponents allow us to pass in the ISO8601DateTime, then manually remove 10 minutes (so that you get your reminder before they go on sale). The UNMutableNotificationContent allows us to add a body (with relevant artist name and venue), a sound, and the user info. We can then set up a UNCalendarNotificationTrigger using our DateComponents and subsequently pass this trigger, along with our notification content (in UNMutableNotificationContent) into a UNNotificationRequest. This request is then added to the user’s Notification Center. Phew!

But that’s not all! To be super snazzy, we added a nice big tick, just to confirm that your reminder is set.

Remember that action sheet? Well, what if I were to click it again, when I already have a notification set up? Would I be able to set notifications over and over?

Wrong. When the action sheet loads, it runs a method to check your pending notification requests. If your Notification Center is empty, it returns immediately, otherwise it runs through your notifications, looking for one with the specific ID of the event you are looking at. The action sheet contains a “set a reminder” or “remove my reminder” option depending on the result of the getPendingNotificatonRequests method.

Something similar is done in the actual removal process — we search for the notification stored in the Notification Center using the event’s ID, and remove the pending request. Again, this comes with a confirmation.

To get your super amazing reminders, simply click “notify me” on any event. If the release day is available, but not the time, don’t worry. We’ll send you a notification at 10 minutes to 9 so you’re ready no matter what.

Flow for setting up local notifications

To recap, here’s how we set up local notification reminders:

  1. Create an action sheet with a “set reminder” option
  2. Check the user’s notification permissions
  3. Set the local notification, passing the onsale time of the ticket to the DateComponent to create a trigger, and interpolating the artist name and venue into the UNMutableNotificationContent
  4. Add the request to the user’s notification center
  5. Update the action sheet to look in the notification center for already-scheduled requests
  6. Finally, set a status alert to let the user know that the reminder is set.

Happy reminder setting!

How does our team sound? We’re hiring!

Action Sheets || Notification Permissions || Local Notifications || DateComponents || UNMutableNotificationContent || NotificationCenter || Status Alerts

--

--