Scheduling Local Notification in iOS
--
Introduction
Local notifications are short, text-based messages that appear at the top of your iPhone’s screen.
On iOS, you can send and receive two types of notifications:
- Push Notifications: Push notifications are sent via the internet, such as chat messages. They’re relayed to your iPhone via the web-based Apple Push Notification Service (APNS).
- Local Notifications: Local notifications are scheduled and “sent” locally on your iPhone, so they aren’t sent over the internet. Typical use cases are calendar reminders or the iPhone alarm clock.
Local notifications are ideal for “local” functionality, such as reminding a user about an upcoming calendar event, a pending to-do list item, or an inspiring quote from your favorite wellness app.
In this article i will share about this Local Notification and how to create it.
Setups Notification Permission
Let’s assume you already have an existing project.
Go to your AppDelegate.swift then add permission for your local notification.
Create Local Notification Helper
Create new class, let’s called NotificationHelper.swift. This class represent helper to create local notification schedule.
Inside this helper you can add necesarry function for Local Notification such as schedule creation and remove notification schedule. But before that, you need to create some model data to passing your schedule data into Local Notification.
Let say i’ll make schedule for muslim prayer time. I need to create schedule model data first.