Opening specific view from push notification - objective-c

I have set up push notifications successfully on my app but I want the user to go to a certain view when the swipe the notification (iOS 5) opposed to just starting the app up.
The view controller is called statsViewController
Does anyone know how to do this? Thanks in advance

You can add a custom dictionary to your push notification payload. See Apple's push notification guide. When you receive the notification, grab the payload and load the view controller based on what's inside.

Related

Apple Watch how to trigger a notification or glance from the main app

I would like to trigger the Apple Watch notification and or the glance views from the main app.
I know how to run them in XCode and selecting those directly, but I need to make them popup from inside the main app programmatically.
In my main app I have a timer that today creates a popup to tell the user something. I would like that same trigger to show the notification view on the apple watch along with dynamic text. To keep it simple for now, suppose I have a button (IBAction). when the button is pressed in the main app I would like to show a glance or show the notification views on the watch. I am guessing this is fairly simple to do but havent been able to make it work, yet.
If you have some sample code that would be great!
Thank you for any help!
While iOS automatically shows notification controller when app receives remote or local notification.
But during development, you can trigger a notification or glance by changing Watch Interface in WatchKit App Schema. (Edit Schema -> (Under Info) Change Watch Interface to Glance/Static Notification / Dynamic Notification ).
However, Selecting Notification requires Notification Payload (create .apns file and set it to Notification Payload while editing schema) as well.
Hope it helps !

handling push notifications to different views

I receive my push notification successfully but when I tap on it, it simply takes me to first view when my app loads.
I want the user to go to specific views depending on the push notification because the user will be receiving many different push notifications (1 for each soccer team, hence possiblity of many different views).
So example: I have a view controller called manchesterUnitedView and somebody just scored so the user receives a push notification for that particular view. When they press it, I want it to take them to the manchesterUnitedView.
Does anyone know how to do this?
thanks
You can use the payload of the notification to pass the information you need to the app, then retrieve it and use it when the app is launched as a result of the user tapping on a notification.
To do this just add a custom dictionary to the JSON payload of the notification and add the information you need to pass to the app there.
See here for details on the payload format.
You can then retrieve your custom dictionary when the app is launched in the application:didFinishLaunchingWithOptions: method implementation of your UIApplicationDelegate and use it to initialize your application state.
See here for documentation of how to retrieve the payload in your UIApplicationDelegate.
I am also interested in this.
The following should work:
I receive the Push on my iPhone and after clicking the "View" Button the App should open, and then i can read the full message.
just like here on this site (bottom): http://www.myfitapp.de/fitnessstudio-app/push-nachrichten/

How to set tab badge from app delegate

I'm trying to set the tab badge number on launch when I receive a push or local notification. Accordingly, I'm trying to set this badge number from the Application Delegate. I can set the badge locally from the tab's view controller with self.tabBarItem.badgeValue, and I can set up a method to set it which I can call from the delegate, but there must be a better solution.
Any ideas?
I don't see any problem with this. It's called the AppDelegate for a reason, so that it can act as the main controller for other controllers.

Is it correct to send Notifications from Controller to View?

I´m building an app which simulates an Inputstream of information from a sensor. When information are detected and parsed I want to send Notifications, that will be observed
by the different views which update themselves to a given timeintervall.
Is its MVC compliant to use Notifications to get a connection from Model/Controller to the View?
I´m asking because I´m often reading about Views sending Notifications to the Controller when a User interacted with the UI.
Thanks
The view is supposed to be just a view and should not have to receive notifications to update itself. I am not saying I have not done this myself as it work having the view update itself. I would recommend that you design your application so that your view controllers receive the notifications and update the views appropriately. Use your views to display and interact with the user sending any interaction updates to your view controller and the view controller sending any display updates to the view.

how to load application on button event of push notification in objective c?

I wanted to know whether it is possible to load the application or some specific page on clicking the "OK" button of the push notification or not in objective c.
As i want to load the application when i press the button of the push notification.Kindly help me out if possible.
Thanking you.
the push notification usually have a "View" button that will automatically launch your application. you don't have to do anything in your app for that to work.
when the user launches the application that way, your app delegate receives a call to
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions,
the launchOptions dictionary containing whatever data was added to the push notification payload by the server.
you can check that and open any relevant page or view, or handle that notification anyway you want.