Handle Push notification during the App running in foreground using swift 4

Updated 26 May 2018

Save

Push notification during the App running in foreground

iOS App is running in 2 mode either the user is interacting with app (foreground)  or minimize  the app (background). if we are talking   about the firebase push notification  then we have to handle by other way because iOS 10 to above provide the custom  local  notification for handling this type of issue when app is running in foreground.

Here I have taken the example of Firebase Push Notifaction.

1: First Set up firebase Push notification in App.

2: Open Appdelegate.swift File:

write this Code for checking the App is running on iOS 10 to above or less .

3:  It will Check weather your app is running in iOS 10 to above or less if iOS app is running on iOS 10 or above then it will assigned the local push notification for handle the foreground app.

4: Now return  the local push notification type like this:

Note:  UNNotificationPresentationOptions.alert  – it will return a alert.

5: It will work when your app is running on foreground and someone send the notification .

6: Now we have to handle the Tap also for this write this function

Note: This method will call when the user tap on foreground Notification.

7: Fire base also provide the other function for iOS 10 to above if token expire , for this write this method to handle this type of case.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

author
. . .

Leave a Comment

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


3 comments

  • ravindra K
    • kunal prasad (Moderator)
  • Rajneesh
  • Start a Project


      Message Sent!

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

      Back to Home