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.
Related
When I open the app it fires the events viewDidLoad and viewDidAppear form my View Controller but when I close it and run it again it does not call any of them.
Any idea?
You need to read up on application states. Here is a link I found online outlining the different states:
http://www.techrepublic.com/blog/software-engineer/understand-the-states-and-transitions-of-an-ios-app/
What you really want is to be notified when your app becomes active.
Probably the easiest way is to implement the function applicationDidBecomeActive() in your app delegate. That will be called when your app becomes active as the foreground app either on launch, or when it returns to the foreground as the active app.
Note that if you want that notification sent to some object other than the app delegate you can listen for the UIApplicationDidBecomeActive notification.
I am updating the watch kit support of a client app for Watch OS 2.0.
The iOS app adds a custom action to local notifications that cause the watch to display a custom button if the phone is locked when the local notification fires.
When the user taps the button, the extension delegate sends a message to the phone using the WCSession sendMessage:replyHandler: method.
If the phone is still locked when the user taps the action's button, I would like to display a message to the user saying "please unlock your phone to " (details about "the stuff" are not important.)
However, in WatchKit 2.0, the Extension delegate is a separate critter from interface controllers, and runs on the watch.
All the methods I can find that display an interface controller, like presentAlertControllerWithTitle:message:preferredStyle:actions: are methods of WKInterfaceController.
How do I display a new interface controller from the Extension delegate? I'm trying to figure this out from the docs (and google searching) but so far I've struck out, despite a fairly extensive search.
I had a similar issue when trying to show UI in response to extension delegate messages.
You can get the root controller through [[WKExtension sharedExtension] rootInterfaceController] but there isn't any way to walk the controller hierarchy from the root controller so it isn't really useful if you have other controllers pushed/presented.
I ended up creating a WKInterfaceController subclass that subscribes to NSNotificationCenter on didAppear and unsubscribes on willDisappear which theoretically should mean only one controller (the visible one) would be listening at a time, though I didn't really test it thoroughly enough to guarantee there wasn't any weird corner cases.
The extension delegate sends a notification when receiving a local or remote notification and the notification callback in the interface controller just calls presentAlertControllerWithTitle:... and all my interface controllers descend from that subclass.
I was trying to show an alert when receiving a remote notification while the watch app was open and not in response to the app opening from a notification action though. I'm not sure what order the interface controller didAppear and the extension delegate handleActionWithIdentifier methods would get called in so you may not have any interface controllers listening to the notification when handling the action. If handleAction... gets called first then you might have to add some logic to the interface controller on didAppear to check if there was some pending notification to be shown and have it show it then.
Target: 7.0 and UP
Testing on: iPhone6 Device
I have been testing Regular Push Notifications (Remote).
I have discovered that if a user clicks on the app icon -- the "applicationDidFinishLaunching:" method is never called.
I have been reading and re-reading the guide on "Handling Local and Remote Notifications" and to confirm that I understood everything referred to: Handling Remote Notifications
It says If a user taps the default button in the alert or taps (or clicks) the app icon, then the app should call its delegate "application:didFinishLaunchingWithOptions" method. And if its a remote notification, it should call "application:didReceiveRemoteNotification:fetchCompletionHandler:".
Neither one of these methods get called if I click on the app icon.
The only method that does get called is applicationWillEnterForeground.
I do have a storyboard file. So the way it loads:
--> navigation controller --> table view controller --> so on
Am I supposed to somehow set the appDelegate in the storyboard file?
I have done a lot of research and so far I have had no luck.
My push alerts do come through so I know that it works. I just haven't been able to determine why these other methods are not being called when the user clicks on the app icon.
Any suggestions or help is appreciated.
The only solution if you want to handle when a user clicks on the app icon is to either A.) set up silent notifications or B.) Set up something on your server so that you can make a request to it to find out if there was a new update.
I found lots of "reloadData" for TableView questions here, but my case is different.
I have a notification App, that uses UILocalNotification to fire reminders.
I need to refresh my tableview in real time after an alert fires, without the need of closing and opening the app to do so...
Example:
User is viewing the scheduled reminders (tableView), when suddenly one of the reminders fires. At this moment, the tableView will reload, but only if the user quits application or go back to another view and open the tableView again. That can't happen cause the application breaks if the user press the row in the tableView witch showed the current reminder (that's already completed and doesn't exists anymore).
I need to reload tableView in real time, without leaving the tableView Controller view. any idea on how to do that?
When a local notification for your app fires while the app is in the foreground, the system sends the application:didReceiveLocalNotification: message to your app delegate. From there, you should notify the view controller (via a direct reference and message send or possibly with a custom NSNotification) to do whatever it needs to do in this case.
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...