Text Countdown Timer Inside Push Notification - ios

I would like to have a timer inside my iOS push notification. Like when it comes down from the top of the screen, I want it to say You have \(time - 1) seconds to respond! How can I code that?

Not saying I would do this, but you could check out the "apns-collapse-id" key in the APNs header. It allows you to send multiple push notifications, and each one will replace the last. You could send one push "You have 120 seconds to respond!" and then 30 seconds later, using the same collapse id, send another "You have 90 seconds to respond". The previous push will be replaced with this one.

Related

ios schedule local notification after a delay with repeats

I need some help with scheduling local notification after a some delay that is repeating every 5 minutes. I'm using UNTimeIntervalNotificationTrigger (https://developer.apple.com/documentation/usernotifications/untimeintervalnotificationtrigger) to achieve repeats with every 5 minutes. But I didn't manage to find the way to delay this.
I can't use dispatchAsyncAfter because app can enter into background.
What I want to achieve is following: When user accept some event (tap on button). I want to have a reminder for him to finish the action. So i have scheduled one notification after 30 seconds, then next after 1 min and then each notification after every 5 minutes until he finish the action.
So basically I need to schedule one time interval local notification that starts appearing after exact 6,5 minutes when user tap on button.
Any ideas?

PUSH issue in iOS10 and swift 3

when my app is in foreground and receive push notification it displays notification on screen. After sometime (2-3 seconds) if user not tap the notification it goes, So my question is how can i handle push notification if user not tap on the notification. When the app is in foreground ios 10.0*
Just for example If user login at another device i will receive
notification on previously logged in device, if app is in foreground
the use will see the notification that login at another device, if
user tap on notification it moves to the login screen, but what if
user don't tap on notification
You could add a ViewController in your app that saved the push notification's data. And when the user navigates there, they can view them.
The duration of push notification is a system defaulted property. The default behavior is for that to show up for 2-3 seconds, and dismissed automatically if it's not tapped. You cannot change the duration of a push notification itself.
Previously, there is a trick that you can have a longer customized sound for your notification which can hold it on screen for up to 30 seconds, but that's from 5 years ago. I doubt that this can still be used today in iOS 10.0

change remote notification time on screen

I have in my app a video chat.
And for the incoming call i'm using remote push notifications.
Is there a way to leave the notification on screen for a longer time then the default?
I need it to be on screen for about 20 seconds.
Thanks

UILocalNotification - Add 1 to CURRENT icon badge

So I've got a UILocalNotification setup to change the Icon badge.
[myNote setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
So it works fine if I don't change the badge number after I set it. If the badge shows 2, lets say, when I set the notification, it changes to 3 when the notification goes off. But lets say that I change it from 2 to 5 within the app before the notification fires, it still changes it to 3 when it does fire.
I need it to be able to add 1 to the current badge number, not the number that the badge showed when I first scheduled the notification. Ex: If it's 2 when I schedule the notification, then change it to 5 in the app, the notification should change it 6 when it does fire.
Is there a way to do it? I'm beginning to hate UILocalNotification.
Thanks guys!
Unfortunately, there is no such API. You can, however, discard all your previous notifications and reschedule them with the updated badge number. But I agree with you, local notifications and badge numbers are bound to reach a brick wall and annoy you.

How to get the payload for an APN when there is more than one of them stacked up?

Consider this scenario:
An application is currently not in the foreground but it is in the background in an unsuspended state (appDidEnterbackground: was called)
The device receives 3 APNs for the application, and the user has the alert style set as "Alerts"
The user clicks Launch on the topmost (4th alert) showing notification alert
didReceiveRemoteNotification: is called and the app can get the payload of that particular notification
The app is now in the foreground with the alert dialog (for the other 3 notifications) displayed on top of it
The user clicks Launch on the notification alert (the 3rd alert) - nothing happens
The user clicks Lunch on the notification alert again (the 2nd alert) - still nothing happens
The user clicks Launch on the last notification alert (which was the 1st one received by the device) - applicationDidBecomeActive: is called.
So my question is how can the application get the payload for the 1st, 2nd, and 3rd notifications?
I can reproduce this 100%, I've noticed that didReceiveRemoteNotification: gets called for the last notification that the device received, and applicationDidBecomeActive get's called for the 1st, with nothing happening for any in the middle.
i.e. if 7 notifications are sent to the device, then didReceiveRemoteNotification: would get called for the 7th, then when the user clicks on Launch for the 6th, 5th, 4th, 3rd, and 2nd alert dialogs nothing would happen, then when they click on Launch for the last dialog (which was for the first notification received) then applicationDidBecomeActive: is called.
I agree with other answers. The best way to store it on the server and read it from there.
Just one more reference to the very similar question/answers:
Handle APNS Remote Notifications while in Background
You can't get this payload. You might also consider, that APNs don't have a guaranteed delivery so you must get infos from the server anyway. The push data is for stuff like showing the user a specific view of your app. In the logic part of your app, the push should only trigger a force update with your server's data.

Resources