iOS push notification interview questions and Answers

Aug 28, 2021 interview

iOS push notification interview questions and Answers

Apple Push Notifications Interview Questions and Answers

Here are the apple push notification interview questions for fresher and experience candidate.voip push notifications ios

What is NSNotification?

 
An Object Which Contains information broadcast to registered observers that bridges to the notification.
NSNotification is the notifier which notify the other class that changes that will happen if some action takes place in another class.
Apple has provided an Observer Pattern in the Cocoa library called the NSNotificationCenter
 
Example : Consider a local notifcation Let take us the 2 controller VC1 and VC2
 
Add the below function in VC1
 
 
 
 
func changetoStudent(notification: NSNotification) {
     ClassChosenLabel.text = “10th Standard”
 }
 func changetoTeacher(notfication: NSNotification) {
     ClassChosenLabel.text = “12th Standard”
 }
 
let we create a notification.name extension
 
extension Notification.Name {
     static let Student = Notification.Name(“10”)
     static let  Teacher = Notification.Name(“12”)
 }
 
 
Let us setup notification observer
 
 
NotificationCenter.default.addObserver(self, selector:   #selector(changetoStudent(notification:)), name: .Student, object: nil)
 
 NotificationCenter.default.addObserver(self, selector:  #selector(changetoTeacher(notfication:)), name: .Teacher, object: nil)
 
 
 
 Add The call button in VC2 as shown in below
 
 
 @IBAction func StudentBtn(_ sender: Any) {
     NotificationCenter.default.post(name: .Student, object: nil)
 }
 
 @IBAction func TeacherBtn(_ sender: Any) {
      NotificationCenter.default.post(name: .Teacher, object: nil
 }
 
 
Here we can observe when we click on studentbtn notification center sends the message to all the listener of name Student
 
voip push notifications ios

2. How can we stop notification to be sent to device in which app is uninstalled ?

When the app the uninstalled the push message has a feedback channel which gives the error message .
The apple push notification service gives the feedback of failed remote notification . the device token of which notification are not delivered  are added in the list of app does not exist .this expired device token remote notification are expired which does not impact the services.
 

3. What is the push notification payload size?

FCM: 2kb
VOIP: 5kb
Remote Notification:4kb
 
 

4.What are the Delegate Method Used in Push Notification in iOS ?

Delegate Method for Silent notification 
 
1. application:didReceiveRemoteNotification:fetchCompletionHandler: is called
 
This method is called when App is at ForeGround . in this method no system alert is shown
 
2. application:didReceiveRemoteNotification:fetchCompletionHandler: is called
 
This method is called when App is at Background . in this method system alert is shown
 
3.application:didReceiveRemoteNotification:fetchCompletionHandler: is called
This method is called when App is at Suspended . in this method system alert is shown
 
4.application:didReceiveRemoteNotification:fetchCompletionHandler: is called
This method is called when App is at Not Running or Kill mode . in this method system alert is shown . There is no CallBack
 
Delegate Method for Normal Push notification 
 
1. application:didReceiveRemoteNotification:fetchCompletionHandler: is called

This method is called when App is at Foreground . in this method No system alert is shown

 
2. application:didReceiveRemoteNotification:fetchCompletionHandler: is called

This method is called when App is at Background or Suspended . in this method system alert is shown. no method is called when user taps on push and app is opened

 

3. application:didReceiveRemoteNotification:fetchCompletionHandler: is called
application:didFinishLaunchingWithOptions: then

This method is called when App is at Not Runningin this method system alert is shown. no method is called when user taps on push and app is opened

 

voip push notifications ios question

Index