How to show notification enable alert after some delay in iOS? - ios

In my app at the time app the launches first time there is an animation on first UIViewController for only 5 seconds. The problem is when app launches first time animation starts and Notification enable alert pop's up, so animation is hidden behind the notification enable alert and as soon as user tap ok on notification alert; animation ended. Because of this notification enable alert user can't see full animation. Please provide suggestion how to fix this ? Is there any way to delay notification enable alert to show after some delay ?

I'm guessing your requesting authorization for notifications in your didFinishLaunching (or perhaps somewhere else). Where ever you're doing it just move it to the completionHandler of the animation and from there add a 5 second delay using asyncAfter.

Related

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

how to give to activity alert in iOS swift?

Suppose App is in foreground and user does not interact with app for 5 min, App should give alert.
Suppose App is in background and it remain in background for more than 5 min App should give alert as soon as app comes in foreground.
Is there any standard way to do that?
For the background part, basically you want to have a Counter. This Counter should do
Observe UIApplicationWillResignActiveNotification notification. And record the time when the selector is called. Let's say it's lastActiveTime.
Observe UIApplicationDidBecomeActiveNotification notification. And inside the selector, compare the current time with lastActiveTime. If it's more than 5 minutes, you'll pop up the alert.
For foreground, you could use some assumptions such as if the top most view controller is the same, assume the user hasn't interacted with the app. You can have a timer that keep checking the top most view controller.

Swift UILocalNotification: Is it possible to fire an event when Notification is displayed?

So I know the didReceiveLocalNotification event is fired when a user selects an action on a Local Notification.
But, is an event fired prior to that when the notification is displayed as a banner or alert when the app is not active? And can that be accessed to do some background code?
I am looking for an answer in Swift if you can help.
No, local notifications do not and cannot awake the app when firing and the application is not active. The user must tap the notification, or perform a developer defined action on it before the app hears anything.
If you need your app to wake up, you need to use a remote notification with content available flag set.

run ios app in background

I'm new to iOS programming, I've managed to create a countdown timer that counts down to 0 and when the timer reaches 0 an UIAlertView pops up to say that the timer is done.
Although my problem is when I minimize the app or if the screen goes to sleep my countdown timers stops and my alert won't show up until I start the app again and let it count down to 0.
So my question is basically, how do I let the app run in the background, or at least let it count down in the background?
Thanks in advance!
The easiest way will be to create a "local notification". When your app enters the background, cancel your timer, but schedule a local notification that will fire at the fireDate corresponding to when your timer hits "0". If the local notification fires while your app is in the background, the user will be presented with an appropriate alert and will have a chance to launch your app.
See the Apple Local and Push Notification Programming Guide for instructions on how to schedule and then handle a local notification.

UILocalNotification - Need to vibrate for a longer duration during the alert / notification

Overview
In my iOS project, I am using UILocalNotification,
when a notification is fired, a custom sound is played.
the custom sound plays for about 20 seconds,
the phone vibrates only once at the start
What I want to do:
Presently the phone vibrates only once at the start. I want it to vibrate repeatedly for 20 seconds just like in Apple's alarm / Timer app before the user pressed on the action button ?
Question
During the alert is it possible to make the phone to vibrate for the 20 seconds before the user can attends to the notification or clicks on the action button ?
Problem
Since my app doesn't have any control till the user presses on the action button I am not sure how I can make it vibrate
The app might be closed when the notification is pops
Is there a way to do this ?
Schedule a timer that invokes the vibration function several times with some delay between calls. Don't forget to add an option to disable the vibration, cause you might get your app rejected from the app store because of this.

Resources