Global app remote notification response ios - ios

I would like to implement a similar response system for push notifications throughout my app. When a remote notification appears and the application is in the active state I would like to place a button temporarily on the screen that performs the same action regardless of where it is in the app.
The only way I can think to do this is to create the same response to notification method in each of the app's many view controller.
Is there any way to do this in the app delegate, tab bar, or navigation bar so that the same response would apply to multiple views rather than placing the same function in each view controller separately?
Please advise and thanks

If I understood your question correctly: your problem is not related to notifications at all, but rather how to place a button on top of all views. A common way would be to add it as a subView to the window.
As a starting point: AwesomeMenu on GitHub

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.

Personalized actions on local notifications

Ive been searching for this information for a day now.
I made a custom notification with some interactive buttons and 2 action buttons (send and cancel).
When I press an action button Im able to get an event on the app side, but i dont have any way to send the information fetch from the notification actions. The userInfo i receive here is the same i gave the notification.
Lets say I can selectable 5 options in the custom view.
What I'm attempting is to return to the app which buttons were selected on the custom notification when the action is pressed.
How can I give the information to the app of the button that was press on the custom view (view controller)?
the response on "func didReceive" its a read only variable
Thank you
You could create a IBAction attached to your specific button, then the next step would be placing your logic inside of said IBAction. Hope that documentation can help!
So I ended up by sharing some code from the main app with the custom notification. Now the notification has direct access to the service, which is something I don't really like but with the lack of time it was the solution I choose.
To do this choose the file from the project you want the notification to have access to, and on right side in the File Inspector -> Target Membership -> Select your notification
Be aware that all the functions used in this code need to be available from the notification project

What architecture can I use to change screens in Swift when there's an event outside of the current view?

For example, I have a Notification that occurs when there is an "unauthorized" error returned from the api server that should bring the user back to the login screen. This event could appear anywhere in the program.
Do I create a new viewless controller to manage states and have it monitor for this notification and then present the login view controller?
I'm thinking about push notifications too, received by the app delegate. Some of these may cause the data model to get updated and then the screen to change. Who should make the screen change? In the past I put all this in the AppDelegate. But there must be a more elegant way!
I also found out about FlowControllers. But they don't play nicely with Interface Builder, at least according to this solution.
Please let me know if you need more specific information about my project.

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.

iPhone UILocalNotification load specific view

I have my local notification working, but when I click View to come back to the app, in the app delegate I am trying to load a specific view, but it wont take. Is this possible or not? It always just comes back to the last view viewed.
When you tap "View" on the notification, it takes you back to your application, and your application shows whatever it was showing before (if it was backgrounded) or is launched.
If you need to show a particular UI in response to the notification, consider implementing the <UIApplicationDelegate> method -[<UIApplicationDelegate> application:didReceiveLocalNotification:]. In that method you can inspect the notification and transition to the appropriate interface.

Resources