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.
Related
Question:
Is there a way to detect if you get a system notification and you swipe away the notification banner (e.g. the alarm that triggers a system notification)?
More practical example:
In your app, you are doing some stuff and suddenly you get a notification from another app. Instead of tapping on the notification, you swipe up the notification (you dismiss it that way). After doing that, I want to capture that in the app.
Why:
Currently, I have a bug in the app, so if I can capture this action, I would be able to fix this bug.
Thanks in advance!
When notification appears, the willResignActiveNotification won't get called, therefore willEnterForegroundNotification won't get called, too.
The best solution here is to catch incoming notification and show the custom view describing this notification instead of system one. Thus, you can detect all actions/timings you need.
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
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.
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...
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.