Check Mobile App
Read now
Start a Project

Local Notification in Swift

Save

A ‘local notification’ is a short text-based message which appears on the top of the screen. It lets users know that there is some information for them.

one can send and receive notification from two type

  1. Push Notification
  2. Local Notification

‘Push Notification’ => It is sent through the internet

‘Local Notification’ =>It is the schedule and sends locally in the iPhone

In this blog, we will learn about the local Notification. Before our application can send any notifications,  we must fulfill the request for sending notifications so that the user can approve or reject it.

For successfully sending the local Notification we have to follow the following steps:-

Steps 1=> First We have to import UserNotifications in Appdelegates, and then we have to create a new 'notificationCenter' property and have to assign an instance of the ‘UNUserNotificationCenter' class to it to manage notifications. This will be our notification center.

For more information about ‘UNUserNotificationCenter’ you can check apple developer link https://developer.apple.com/documentation/usernotifications/unusernotificationcenter

 

Steps 2=> In the ‘didFinishLaunchingWithOptions‘ methods we will declare option for our notification, we will use the ‘badge‘, ‘sound‘, and ‘alert

 

Before sending the notification we have to ask permission from the user

It will look like this when app launch

 

Permission for Notification

Step 3= > Now to trigger the ‘Notification’ we will create a method and call it when we like to call, like on any button click

 

We have set the time interval of 4 seconds. So, after 4 seconds the notification will show when the apps in the background

Local Notification appears

Conclusion

So please follow the above step to integrate Local Notification, and if you have any issue or suggestion you can leave your query/suggestion in the comment section.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home