How to set an Alarm in latest iOS using Swift - ios

In iOS 8, Event Kit was released along with the ability to use EKAlarm.
More info here: http://www.techotopia.com/index.php/Using_iOS_8_Event_Kit_and_Swift_to_Create_Date_and_Location_Based_Reminders
Has anyone tried using this to setup Alarms in iOS using this?
Because alarms are notoriously difficult to work with in iOS in terms of launching an app from background mode, I was hoping to use EKAlarm. Would EKAlarm be a better option than setting up Local Notifications?
As of iOS 9 or 10, is there a better way to setup alarms other than having the app stay in foreground the whole time?
Most posts on SO suggest to use UILocalNotification, however, in my situation, I need additional things to happen in my app aside from a system alert (notification) the user receives. Additionally, it seems that UILocalNotification has a maximum of 30 seconds to play a sound. Obviously, an alarm needs more, and provide the ability to snooze, and other options provided within App.
Having said that, is UILocalNotification really the best option here?

Related

Some app fires alarms more then 64(local notification) , any way to manage this?

In my app i need to update locally settled alarms with local notifications, after 64 has been fired then set new 64 is remaining even though app is killed by user.
This means it needs to update alarms while app is killed.
In iOS that is not allowed, but
Some applications like Alarmy, Alarm Clock Pro, dozen are doing some what like this.
So is there any way to get this?
Any help will be appreciated
Thanks
I've encountered the same problem. What I've done was to create a queue and on every launch of application I rescheduled notifications based on the queue. 64 can be scheduled and the others are in the queue according to their fire date. I've also created silent push notifications that would arrive every n hour in order to force my app become active. With this approach, I could take care of that queue even if the user doesn't open the app. Your goal can be achieved but it is really difficult to implement.
After all, iOS ecosystem does not let third-party apps that have the same functionality as OS 's default apps to thrive. So basically if you're creating an alarm app you should better think again.

Is it possible to build an alarm clock such as the built in app from Apple?

A lot of todo-list apps such as Wunderlist offer some kind of reminder feature which usually just fires off a notification.
But I have never encountered an app that offer a similar notification view as the built in preinstalled alarm clock. You know, that locks the phone and offers a snooze option.
This makes me wonder if the alarm clock functionality that is built into the preinstalled iOs app from Apple including setting time or add a snooze button etc is only available for that particular app?
Since I'm a designer without any coding skills I only want to know if it possible or not.
Unfortunately this is unavailable for developers. You can check all of alarm clock apps in AppStore, all of them are using the standard local notifications. Which will fire once and that's all. You can of course set your custom sound and change couple of options, but it will never work like one build in Clock app inside iPhone.
You can read more about local notifications in Apple documentation: https://developer.apple.com/reference/usernotifications/unnotificationrequest
I figured Alarmy is constantly playing (when there is an alarm set up) a silent sound in the background. Like Spotify, but silent. This keeps the app active all the time. I came to this conclusion by logging the result AVAudioSession.sharedInstance().isOtherAudioPlaying (Swift 4) in my own application. Whenever Alarmy is terminated it returns false, whenever Alarmy is running in the background it returns true. Same thing happens for the app linked by Ernesto Elsäßer.
I used the same technique and I also used this pod to trigger a function when the time comes and start the real music.
I did this for testing and am not going to make an app out of it because playing silent sounds in the background is against Apple's rules. I don't know how Alarmy (or other apps that use this same method) got away with it.
Some related questions:
How do you constantly run in background?
App “Alarmy” is able to play iTunes song from background state… How?
Wake up application in background using AudioSession like Alarmy iOS app
Also you can check this article out.
This app seems to do exactly this, but I have no clue how ...
I tested it, and it managed to start playing music on a locked device at an arbitrarily chosen time, and for way longer than the 30s timeframe allowed for notification sounds. Further, the music is streamed from an online radio station, meaning they found a way to ...
wake up the app from a scheduled notification without user interaction
create a socket connection to a radio station in the background
start playing sound in the background for an indefinite amount of time
I also tried out the alarm in Airplane Mode, and it still played a locally stored backup song, so it probably doesn't abuse the VoiP background mode or push notifications, but really is triggered by a local notification ...
So although I can't tell how, it looks like there is an App Store Review-proof way to create a real alarm app.
(I am not affiliated with the developers of this app, just did some research on what's possible.)

iOS - Play ringing sound when "called" in background

I was wondering if it was possible to play a continues sound in my Skype like application when a user is called an the other user has the app installed but the app is in the background in the moment.
It would be really awesome if it could could show an "accept / decline" on the lock screen. But that might not be possible is it?
I have looked around on the internet, but I could not find it. (I think I saw something related to this on a keynote once, but that might just be my memory hoping it exists.)
That is possible to show an "accept / decline" on lock screen or notification itself. The only thing that is not possible to do is to make input field for quick response (as it's done in Messages app)
There is nice guide to interactive notifications for iOS8.
To play sound i suggest you to use possibilities provided by UILocalNotification instead of implementing custom sound/vibration.
Also, if your app is in background, it must use push notifications, so for VoIP apps i suggest you to take a look into PuskKit framework and special type of pushes - VoIP pushes

Trigger iOS app periodically

I'm trying to figure out if there is any permissible way to have my iOS app run periodically (say every 4 hours) and grab a users location. I'm aware of three possible ways this might be accomplished:
Local Notifications (Handling Local and Remote Notifications)
The problem with this solution is that when the app is killed after being in the background a while or the phone restarts, then the local notification will fire and give a UI but not actually start the app so I can't grab the location.
Alarms (Configuring Alarms)
As Apple's documentation says:
Note: An alarm is not intended to serve as a UILocalNotification. An alarm requires you to create an event or reminder that is visible in the user’s Calendar or Reminders app. A UILocalNotification is better suited for general purposes that don’t involve the Calendar database.
Therefore, not only would I be going against Apple's recommendation, but I would then have to ask for access to the user's calendar which won't make any sense to the user.
NSTimer (NSTimer)
I could create a NSTimer, but that solution was already answered here as not viable (That was three and a half years ago but I'm guessing the answer hasn't changed).
Are there any other ways in which this might be accomplished on iOS?
I don't know of any way to grab it periodically every X hours, but the Significant Change Location API might work for your use case. It gives you updates whenever there has been a significant change to the users location.
edit
If you app is not running in the background it will relaunch your app.
/edit
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW10
This stack overflow question has a lot of info about this service also:
Behaviour for significant change location API when terminated/suspended?
See the Getting Location Events in the Background section of Apple's Location and Maps Programming Guide. The other methods mentioned in the question wouldn't actually wake the app up, except for UILocalNotification, and then only when the user tapped in in Notification Center.

Making iOS wake my app up on a specific time

I'm trying to create a little reminder-app for my special needs ;-)
Is there a way to tell iOS to wake my app up from the background at a specific time/in regular intervals?
The app would then decide to turn on the screen or play a sound, if required.
So far I can't figure out how to do this. All I can find on iOS 7 multitasking is about playing music, downloading data etc. Nothing time based...
As far as I know, it is not possible.
The closest you can get to that is by sending either a local or a push notification.
Take a look at local notifications: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html
The main class is UILocalNotification, documented at https://developer.apple.com/library/ios/documentation/iphone/Reference/UILocalNotification_Class/Reference/Reference.html

Resources