receive push notification when a certain date expirespush notification - ios

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.

Related

Any way to know that a local iOS notification was displayed to the user if the user did not interact with it

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)

Suppress/Hide push notifications in iOS when the app is running

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.

Apple push notification-like service, only when running in foreground

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.

Push Notification send and receive in iOS?

I want to develop an app regarding push notification.
I want to send a push notification to 5 persons who has installed my app and are stored in my directory.
Can I send Push Notification to 5 people using their UDID which I received from each and every person who has installed App. (As UDID is banned)
I want to send them continuously to 5 persons till one does not press OK button on Alert?
Which service should I use for Push Notification?
Is push notification receives on time or it delays?
You cant send the push notification using UDID, you can use the Apple service for sending the push notifications via device-token and pem file which is explained in below link.
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Any push notification that isn't delivered immediately was queued for future redelivery because your device was not connected to the service. "Immediately" of course needs to take latency for your connection into account. Outlying cases would be beyond 60 seconds as APNs will time out at that point.
Still you have any query then you can refer the below link http://developer.apple.com/library/ios/#technotes/tn2265/_index.html

Recover UILocalNotification or remote push notification anytime

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.

Resources