This question already has answers here:
Is there any way to detect iOS 9 low power mode programmatically?
(4 answers)
Closed 7 years ago.
I need to get low power mode status, weather low power mode is on or off alert in my app when iPhone change its power mode.
Please help me by getting the solution.
Thank you
There are two ways for that.
You can register for Power State Notifications.
[NSNotificationCenter defaultCenter] addObserver:self selector: #selector(yourMethodName:) name:NSProcessInfoPowerStateDidChangeNotification object: nil];
Or you can determine the current state.
[[NSProcessInfo processInfo] isLowPowerModeEnabled]
The best thing what i think its really great for user experience point of view as per the Apple documentation is: Your app should take additional steps to help the system save energy when Low Power Mode is active. For example, your app could reduce the use of animations, lower frame rates, stop location updates, disable syncs and backups, and so on
I know there is already an answer for this (as per the comment dandan78) with links only no description, so posting bcoz it will be good if we have something here as well.
Related
I'm currently working on an iOS app that ranges and monitors an iBeacon in order to be able to do some actions and receive notifications.
Ranging is working flawlessly, but I'm having troubles with the beacon monitoring and the notifications. I've researched quite a bit about the subject and I'm aware that CoreLocation framework has usually problems like this, but I was wondering how other devs are fixing/approaching this.
Basically, I'm showing local notifications when didEnterRegion and didExitRegion methods are fired. Unfortunately, these two methods are being fired quite often (in an unreliable fashion), even when the iBeacon is right next to it, although sometimes is works perfectly, which makes it more annoying.
I've tried lowering the iBeacon advertising interval, and although it helped, it didn't fix the issue completely. Now, I'm trying with a logic filter where I ignore firing the notification if the enter or exit event happened in the last X minutes (I'm thinking of a 'magic' number between 5 and 15).
Is anyone having the same problems? Would adding a 2nd iBeacon to the situation help? (maybe monitor both of them, and filter logically the exit and enter events based on those two inputs?).
I was also thinking in adding another layer of data to show notifications, maybe based on GPS or Wifi info. Has anyone tried this?
Any other idea? I'm open to any recommendation.
Just in case, I'm using Estimote iBeacons and iOS9 (Objective-c).
Thanks for your time!
Intermittent region exit/entry events are a common problem, and are typically solved with a timer-baded software filter exactly as you suggest. The specifics of how you set up the filter (the minimum time to wait for a re-entry after an exit before processing exit logic) varies for each use case so it is good to have it under your control.
Understand that region exits are caused by iOS not detecting any Bluetooth advertisements from a beacon in the CLBeaconRegion for 30 seconds. If two detected packets are 31 seconds apart, you will get a region exit and then a region entry one second later.
This commonly happens with low signal levels. If an iOS device is on the outer edge of the beacon's transmission range, only a small percentage of packets will be received. With a beacon transmitting at 1Hz, if 30 packets in a row are missed, the iOS device will get an exit event.
There are several things you can do to reduce this problem in a specific area where you want solid coverage:
Turn your beacon transmitter power up to the maximum. This will give stronger signal levels and fewer missed packets in the area you care about.
Turn the advertising rate to the maximum. Advertising at 10 Hz gives 10x as many packets to receive as 1 Hz.
If needed add additional beacons with the same identifier to increase coverage.
Of course, there are costs to the above, including reduced battery life at high advertising rates and transmitter power levels.
Even if you do all of the above, you still need the software filter, because there will always be a point where you are on the edge if the nearest beacon's transmission radius.
You can see an example of software filter code in my answer here.
Beacons emit a pulsing signal. Ranging also performs an intermittent scan (roughly every 100 ms). This means that it is possible for your device to miss beacon for a few seconds in a row, which can cause the results you are experiencing. You can log the beacons RSSI value in this method:
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)iBeacons inRegion:(CLBeaconRegion *)region
I believe you will see a lot of zero values before seeing didExitRegion being called. This isn't a fault in your code, or with the beacon. This just has to do with the fact that neither the signal being emitted or the detection are constant. They are pulsing. These problems can occur while the beacon is just sitting on the same desk as your device, and can be exaggerated in a real world setting when the signals are blocked by physical objects and people.
I would use ranging to determine more accurately if your beacon is around. Note that ranging, especially in the background can have a significant battery draw.
For short pieces of content, the Sonos crossfade feature is not desirable and ideally I'd like to be able to disable it for tracks with a small duration but this does not appear to be possible via the API. If it is not possible, I'd like to attempt to game it. Is crossfade implemented with a fixed duration or is there some kind of signal analysis going on?
There is currently no way to adjust cross-fade through APIs. It is done with a fixed timing of 12 seconds (6 seconds for the end of one track, 6 seconds for the beginning of next track).
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
iphone: Calculating battery life
I would like to know if its possible to calculate the battery lifetime on iOS. So, for how much time I can use my device until it is 0% of battery percentage.
Thank you all! :)
In short, you can't. At least not with any accuracy.
Or, really, you can't unless the user is going to continue doing exactly what they are doing right now without any changes in network, signal strength, ambient light, etc... As well, receiving push notifications and/or taking phone calls can impact battery life. So can media playback, including -- even -- the encoding format used within the media.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
So I am building a small application that has a keyboard and a few other buttons that trigger audio samples.
For this application, there are several pre recorded audio tracks (drums, vocals, guitar) which can be muted/unmuted... I have that part working fine with AVAudioPlayer
But, as most of you know, AVAudioPlayer is a little slow and has some latency if its assigned to say triggering a small audio sample of a drum hit or a synth. So i implemented SystemSoundServices to play the short sound samples. It is working fine as far as the latency between hitting the button and the sound playing, but I have a slight problem. When the sample is say, hit twice repeatedly, you hear a small popping sound, which is expected because its cutting off the first sample from playing when the button is hit the second time.
I would like to solve this by basically detecting if a sample is playing, if it is, then set the volume to 0, stop playing, and then play the sample again. BUT systemsoundservices unfortunately doesnt have this functionality built in. AVAudioPlayer does but it is too slow. I know there is CoreAudio, AudioQueue, Open AL, but these all seem WAYYY to complex for what i need to be doing. I dont need to do audio processing of any kind.
Does anyone have any suggestions of an audio framework that doesnt require writing 100 lines of code just to play a short audio clip? EVerything seems to be pointing me to spend weeks learning CoreAudio/AudioQueue/OpenAL and that just seems like a waste of my time for what I am working on.
you can use an AUSampler for the sampler. granted, it is more complex than SystemSounds. the AUSampler is a system-supplied AudioUnit. so you'll have a little programmatic AU configuration to do, but the hard stuff is out of reach.
you can use AudioFile and ExtAudioFile for reading and creating audio files. in the case of the AUSampler, it knows how to load samples (in a subset of available formats), so you won't even need to write the file i/o parts.
for more complex audio, you will likely need to come to grips with working with audio streams yourself.
you don't mention if your audio tracks are compressed or not, but if they are short you might try using .wav or another uncompressed format. AVAudioPlayer will not have to take the time to start decompressing them. It still has a short delay but it is not as long as with a MP3.
Beyond that, I think buckling down and learning one of the lower level frameworks is going to be what you need to do.
Here is a nice easy intro to OpenAL, if you like that:
http://benbritten.com/2008/11/06/openal-sound-on-the-iphone/
EDIT: Also - you're using the prepareToPlay method call before calling play, correct?
My solution was as follows. I create three Avaudio Players with the same URL.
When I am about to start the sound I use the property isPlaying to determine which Avaudio to play.
The sound fade out with the method, performSelector:WithObject:AfterDelay. While the sound is fading out the user can play the keyboard again and the second Avaudio, and so on and so forth.
The number of Avaudio you will need is according of how fast you fade out the sound and how fast you want the user be able to play.
This question already has an answer here:
iphone: what libraries or APIs need to be used for CPU , RAM usage in iPhone
(1 answer)
Closed 8 years ago.
I would like to see what my app is doing with system resource while users are using it. Ideally on the view I can print real time CPU and Ram stats and then have the user report back to me the max or min etc.. of these values. My feeling is that this will help us test the nuances of some advanced UI things.
Any ideas on how to make this happen?
Thanks in advance
I don't think there is a way to get that information about your App from the iPhone SDK. It shows you this info in Instruments but that won't be available on your App.