I have a problem. When user receives a remote or local notification but he don't read , the notification lost from "userInfo" if the user open the app tapping over the app icon (not on the notification in the Notification Center)
Is there any way to recover the last notification "userInfo" anytime?
Thanks!
I don't believe there is. It would be up to the application to keep track of the info in any notifications that it schedules. Then when the application is loaded, you would have to look through the list of these saved notifications to find the most recent one that has already expired.
In the case of a push notification, this would probably require querying a server to determine what push notifications had previously been sent to the device.
Related
I have an app that has the Firebase Realtime Database as database.
In the app there are different products that expire after a certain time.
The database contains the expiry date and the exact time. How do I get the user to receive a push notification if the product is only available for 10 minutes, even if the app is completely closed?
Do I have to save the data on my device and send a local push notification from there?
Currently the user only receives a push notification when a new product is added.
A "local push notification" isn't really a thing. There are local notifications and push notifications. Push notifications are sent (pushed) from your server, through Apple's APNS (Apple Push Notification Server) and to your app's user.
You can schedule local notifications locally for some future time. There's really no difference to the user. It displays a message in the notification center which the user can tap to wake up your app, even if it wasn't running when the notification "goes off."
It sounds like you want to schedule a local notification.
If the trigger comes from your server then you could trigger a push notification. Those are also displayed to the user in the notification center whether your app is running or not.
I am trying to write a notification tracking system for my app. My understanding is that a scheduled local notification is guaranteed to get delivered but that my app won't get a notice that it was delivered unless the user interacts with that notification in some way. Am I missing something? Is there some event or notification sent to the app simply to indicate that the notification appeared?
No, I don't think you have any way of knowing about the "notification not taken."
A Jailbroken device would be a different matter.
There are silent push notifications, and I haven't looked at the new notifications API in iOS 10, so I guess it's possible Apple added a silent local notification for iOS 10...
Actually there are 2 scenarios:
App in background: When a local notification is delivered by the system, app is not notified, only if user interacts with notification view app is awakened.
App in foreground: App is notified when a local notification is delivered by calling didReceiveLocalNotification method.
Local notifications are guaranteed to be delivered only is user allows this (app will ask user to allow to receive local notifications)
I have an app to work on. And I need to know if there is already some push notifications before the app is opened. Is there a way to solving the issue?
Thanks
You can't push a notification to a device when your application hasn't been opened at least once - the user has to authorize push notifications and you need get the push token value - returned after calling registerForRemoteNotifications - and send it to your server.
There's no guarantee that your app will see multiple push notifications if they all arrived when the application wasn't running. Often you'll just see the most recent notification. You should store all of the notifications on your server and have your application request them when it becomes active if there's at least one notification waiting for you.
Once you've registered for notifications you need to setup didReceiveRemoteNotification method in your AppDelegate. There you can handle any information received from a Push Notification. Here's a link to there relevant documentation.
I receive push notifications on certain events from a notification server we have.
I do want these notification alerts to appear when the app is not active in the background/foreground
I don't want the notification alert to appear when the app is active in the background (foreground not a problem since the notification doesn't show anyway). I want to show my own local notification, only.
Is there any way to do this from code? Basically I want to hide the remote push notification and instead show a local notification when my app is active.
P.S - The notification server sending silent notifications is not an option - the server does not know when our app is running/not running. There is no communication between the app and this server.
You can notify your application first and then show a local notification with that. To perform this you can simply send content-available notification from server. This makes your app notified and then you can decide on showing local notification or not.
I have an iOS app that needs to update its content while running in foreground automatically. My app does NOT need to update if in background.
There is a existing way to do so, which is APNS(Apple Push Notification Service).
Because I don't want users to see notification message while in background, using push notification without alert or message might be a solution.
However, if using APNS, iOS would ask users to confirm if they want to receive notifications by my app. I think that users may be confused when being asked by the OS since my app does not actually push notification to users.
The current method I use is keep pulling my API every 30 seconds to see if new content is available. This method would fail if there are too many users.
Is there any 3rd party push-notification-like service that provides notification while app runs in foreground only? (no need to get notification while in background)
You can use Silent notification for that, in this
In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications. if you send the APS payload with just the content-available set to 1, users will not be notified of the notification.
And the notification arrives in application:didReceiveRemoteNotification:fetchCompletionHandler:
Your payload is like
{
aps: {
content-available: 1,
sound: "default"
}
}
In case of push notification, it is necessary for user to accept push notification on application 1st run. You can set a silent push notification also and for this user will not get any alert of getting a notification during application run loop.
If you want to avoid push notification, then you can only set a NSTimer that you are doing already.
There can be a 3rd case, Application only sync with the server when it comes to foreground. And for this you can refer to my this post.