present specific view controller when tap on push notification - ios

I am new to push notification concepts and understood the basics of push notifications. But, I am not getting to present or push a specific view controller when tapping on push notification. And the same time how to handle dependency presenting view controller(example: if required same data from the server along with notification data to present view controller, how to handle it)
And how to handle notification if the app is in the foreground, background, or closed scenarios.
Please help me, Thank you.

Related

Navigating to a particular Screen through Firebase Push Notification in iOS Swift

I want to naviagte the user to a particular view controller after clicking on the push notification in which I will be sending a route with the screen name of the view controllers from Firebase (through key-value). I'm not sure how to go about it and I'm supposed to write that piece of code.
It would be of great help if anyone could help me with that.

Message notification when inside another view controller

I'm carrating on an app that was written by a programmer before me. It has only 2 view controllers: the main one displaying chat (its the root view controller) and a second one to tinker with your profile. I was asked to implement some kind of notification (preferably one that pops up at the top of the screen) to the user that a message has arrived when they are inside that profile-tinkering view controller. Must I use the APNS server technique, or can I use an easier technique by utilizing the App Delegate somehow?
Use APNS, I prefer the local notification,didReceiveLocalnotification method will get called,then display an alert
Use delegate,assign delegate to the profile controller,and implement the required method,when you have a message arrived,display an alert
When you are inside another view, the APNS wont get displayed because the application is already in foreground.
When app is in foreground and you receive an APNS, didReceiveRemoteNotification method will get called.
You can read APNS package here and notify user of this in a way you want, for e.g. you can display an alert.

How to perform an action when a user slides up a push notification in iOS

I want to perform a action when a user slides up a push notification on home screen in iOS. Precisely which functions gets called when a user slides up a local push notification.
I could be wrong, but I think you cannot get that kind of event..

Segue to a view controller when app opens from a NSLocalNotification

I need a way to segue way to a view controller when the app opens from a NSLocalNotification.
I don't really know where to start and I can't find any examples on how to do it online. Any suggestions are appreciated.
Where to start:
Do you know how to initiate a segue through code? If not, see the UIViewController docs and search around here for prepareForSegue and performSegueWithIdentifier There are lots of hits. Also this is a good tutorial: iOS 5 Storyboard: How To use Segues, Scenes and Static Content UITableViews but there are many out there.
Have you worked with UILocalNotifications? See the UILocalNotification Programming Guide for an overview.
In terms of handling the event, that is done by the UIApplicationDelegate See the event method: application:didReceiveLocalNotification:
Local notifications are similar to remote push notifications, but
differ in that they are scheduled, displayed, and received entirely on
the same device. An application can create and schedule a local
notification, and the operating system then delivers it at the
schedule date and time. If it delivers it when the application is not
active in the foreground, it displays an alert, badges the application
icon, or plays a sound—whatever is specified in the
UILocalNotification object. If the application is running in the
foreground, there is no alert, badging, or sound; instead, the
application:didReceiveLocalNotification: method is called if the
delegate implements it.
How you handle a UILocalNotification will depend on the state of your app: foreground, background, inactive.

IOS Is there a way to send user to particular view after tapping "view" on notification?

I am using push notifications in my app and I would like to send user to particular view, not the view he last saw. Is it possible?
You need to implement the appropriate AppDelegate messages.
Specifically, you will receive the APNS payload on the application:didFinishLaunchingWithOptions:
You might also receive the payload in a different message, application:didReceiveRemoteNotification: if the application is active.
Then when you know that your app was launched because the user touched a notification, you can direct him to a specific view accordingly.
I don't think that you have control over what the user sees while app is starting app (opening animation). After the app is fully active, you can send him wherever you want to by opening proper view controllers, setting proper tab, etc...

Resources