Is there a way to get a callback or some other notice when a user has read or "seen" a push notification from my app?
You get a callback only if the user taps on the notification to open the app. In that case either didReceiveRemoteNotification (if app was active or in the background) or application:didFinishLaunchingWithOptions (if app wasn't running) is called. In both of them you can access the dictionary containing the push notification data, and callback your server if you wish.
Related
I can get the FCM onResume method to be called when the user taps on one of the notifications. But the other notifications all also have Data that I want the app to receive.
How can the app get the data of all other notifications that have been received while the app was in the background when the user taps any one of them?
I am working on an iphone app where I store all the local(and push) notifications for my app. There will be a screen on app which shows all the notifications generated by the app. My question is that can an iphone app know when a local notification for that app is shown. for example, suppose that a local notification is shown, but the user simply ignores that notification, and does not tap on it, so in this situation, can my app somehow find out if the local notification was shown and do some processing on it(for example, store the notification data in sqlite database).
I have tried both "didFinishlaunchingWithOptions" and "didReceiveLocalNotificatios", but from my understanding, they are invoked when a user laucnhes app by tapping on the notifiaction, is there a method by which I can have the notification data even when user does not tap on the notification.
tldr; can an iphone app handle(process) local notifications even when user does not launch app by tapping the notification.
No, your app wan't get any notification whcih user has ignored. Your app will notified only when user presses view or tap on that notification.
This question already has answers here:
Relaunch iOS app without user interface when application in background?
(4 answers)
Closed 10 years ago.
Please suggest me objective c code for bringing the app from background to foreground without any user interaction when push notification comes.
Unfortunately it is not possible as Notification come and your app started automatically even without user interaction.
As Push Notification comes it Handles by OS.
If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.
Then It means user have to interact with the Device.
From The Apple Doc.
When the operating system delivers push notification (iOS or OS X) and the target application is not running in the foreground, it presents the notification (alert, icon badge number, sound). If there is a notification alert and the user taps or clicks the action button (or moves the action slider), the application launches and calls a method to pass in the local-notification object or remote-notification payload. If the application is running in the foreground when the notification is delivered, the application delegate receives a local or push notification.
That's All.
I hope it clears to you.
I dont think its possible. Once push notification came, the os itself handles and show notification if it is enabled for your app. Then from the notification, if you are going to app, then didReceiveRemotenotification callback will be fired.
Thanks.
It's possible but it would require a jailbroken iPhone and hook the push notification receiver to launch your app when the notification is received.
If you aim for App Store you can't.
When my application is not active (in background) I recive local notification. After click on this notification application became active. Is it possible to activate application after I recive local notification automaticaly, without clicking on it
No, this is not possible.
From Local and Push Notification Programming Guide
If there is a notification alert and the user taps or clicks the
action button (or moves the action slider), the application launches
and calls a method to pass in the local-notification object or
remote-notification payload.
An action performed by the user is required.
No,
you cannot start any application automatically from background without user getting some actions.
So, for local notifications, application cannot be resumed from background even if local notification is fired. User has to click on notification to open application.
Hope this info helps you..
Launch app from homescreen can't get remote push payload? But launch from Notification Center works.
At first, app is NOT running. After received remote push notification, user doesn't launch app with the notification at once. Then user taps on the notification in Notification Center to launch app, I can get the push payload from launchOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(userInfo) {
//do some works with push payload.
}
}
But if the user launch app by tapping app icon from homescreen, I can't get the push payload from launchOptions, although application:didFinishLaunchingWithOptions: is called.
Again:
App is NOT running.
User doesn't launch app when received push notification.
Later, launch app from Notification Center and get push payload from launchOptions.
Launch app from homescreen can not get push payload from launchOptions.
Is this a bug in SDK? How can I get push payload by launching app from homescreen?
Thanks!
You can't.
You only get the payload when launching from Notification Center because it means the user is interested on that notification.
For example, if I get a reply on Tweetbot and I want to see it, I tap on the notification, but if I only want to check my tweets, I open the app normally.
If the payload has information that the user HAS to receive, the app should contact your server and retrieve it.
Yes, if the user launches the app by tapping the icon, the payload of the remote notification is lost.
It is not cool but it is the way it works at the moment.