I'm trying to create a kind of alarm clock app with the swift but I could not figure out how to set an alarm model. I've tried UILocalnotification but I don't want my users to be involved the flow of alarm app other than setting the alarm. Then tried NSTimer and NSRunloop etc. but that didn't work either since those don't work when app gets background. So is there any alternative ways to do that? Any help and suggestion would be appreciated, thanks.
I have been doing research on this for quite some time now. But didn't find any concrete way to do it. You have to use one of the following from the list and make a logic to awake the app from the background.
For the alarm you can go through the blog here. It's having the details, which you can use to make a logic with UIApplicationExitsOnSuspend in info.plist file.
As already suggested, since iOS 7 the only way to have an App running in background is allowing one of the Background Modes.
Background modes
You can find them in the Capabilities section in your project settings. As long as your App does not fall under one of these, you are out of luck :(...
I once tried to write a similar App to yours, and there is really no way to do that right now.
Cheers,
TK
Related
i have a big problem. I am working on an app about accessibility. The app should work through the iPhone microphone to take over sounds from the environment (indoor) and compare them in real time with sounds in the app database (recorded from users previously). If sounds match, the user will be warned by the app through a notification. So... firstly, the app should listen sounds working in background, but after some minutes, iOS closes the app in background automatically. IS THERE SOME SOLUTIONS FOR THIS PROBLEM? TO ALLOW THE APP BE OPENED AND WORKING?
Secondly, do you know in which way is possible compare sounds recorded with sounds listened by microphone in real time?
Really really thank you. 🙏🏻
Regarding the problem that your app is automatically closed, it seems that something was not configured properly in your project.
When the UIBackgroundModes key contains the audio value, the system’s
media frameworks automatically prevent the corresponding app from
being suspended when it moves to the background.
Make sure that you have enabled the "Audio, AirPlay and Picture in Picture" background mode in your project.
Fore the first question:
Because your app will be recording the audio while in background, you can:
set UIBackgroundModes key in your app’s Info.plist file to audio.
It should keep your app alive when you press Home button. See the Declaring Your App’s Supported Background Tasks section
At some point, iOS can kill your app due to some conditions, but
eventually it would restart your app later.
And be careful with this, you might have to deal with Apple Review team to prove that your app is not doing something harm to user privacy. Otherwise, they wouldn't let it go live.
For the second question:
I think you can use some AI/Machine Learning service out there to do so. It's much more accurate and faster than building it your own.
I'm trying to make kind of a reminder app and for that to work I'll need it to auto start when the phone comes on in order to track the time. Was thinking of using Messaging Center but that would only work when the app is active and running already. I'm using Xamarin.forms so would appreciate if someone could point me in the right direction.
Android has an AlarmManager that can start a service at specific times.
iOS has no such feature, and hence it can't be done on iOS due to security restrictions.
The only think I could think of, is to schedule a LocalNotification on iOS that the user would then have to press to open the app, but at least it would be a reminder of sorts. Not sure if that will suffice.
I am new IOS developer using swift. I have created a Radio App (streams Live). I want to make it to run in the background when user minimize the app or do some other stuff. Right now, it stops streaming audio as soon as sent to background and continuous again as soon as it is brought to foreground.
I searched few articles and other forums, but couldn't find any help. I am really new to IOS development and don't know about controls/functions in the AppDelegate.swift.
So far I enabled the option under Project Capabilities Tab as following also made change in info.plist file, however Application still stops as soon as enters in the background.
Any word of advice will be greatly appreciated. Thanks for your time and views.
I have adding the bool to info.plist file saying "Application does not run in the background = "NO"
Now I can run app in the background. I hope this solve the problem for others as well.
I want to develop an Enterprise Application. It will run in the background continuously and from the background i want to open an another application. Its like toggle between two application. I have implemented forever background running with help of Location services which is working fine and also updating the location from the background but it is unable to execute openURL method.
Please suggest something.Thanks
It's not possible!
You can use these links only.
https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html
I will extend a little bit on MobiDevCom answer.
I haven't found a good publicly known solution.
The direct approach (trying to open something from background using all kinds of public or private API) ends up requiring all kinds of entitlements. I tried at least dozen of things about a year ago and reverse engineered quite a lot of iOS components.
The only idea which I found was usage of MDM Guided mode (however, a device needs to be supervised and enrolled into MDM for that).
BTW. Here is the question which I asked - Show some UI from background in audio player or VOIP app on iOS
Is it possible to control the native Clock app from my app?
Is it for instance possible to start its timer, or disable and enable an alarm? I want my app to start up, do a modification, and then die.
If it's possible, where do I find more info about this?
This will be my first app. Thanks in advance!
Im pretty sure it isn't doable within public APIs, and i would be very surprised if it was doable at all. What are you trying to do?