My device is iPhone 5s running version 8.1.3. When any location based application runs in the background, the status bar becomes blue and big, thereby pushing my app's views down.
Is there any way that I could identify if any app run in the background and resize my view? Usually how is this handled?
Attached images.
Yes. Your app delegate can implement these methods:
-application:willChangeStatusBarFrame:
-application:didChangeStatusBarFrame:
and these local notifications will also be sent to the default notification center:
UIApplicationWillChangeStatusBarFrameNotification
UIApplicationDidChangeStatusBarFrameNotification
Related
is it possible to determine how many times my iPhone has been locked and unlocked programmatically when app is foreground and background as well. Code snippet will help a lot...
There's no way to get this information from your App.
You can only know when your app goes to foreground/background via your App Delegate, but not what the user does outside of your App.
For my current project, I need to calculate the total time while an iOS device is unlocked i.e. the user is working on his device. I am aware of the Darwin Notifications as available in CFNotificationCenter as specified in this Stackoverflow question. I have tested this code on my iPhone 5C. It is woking fine for foreground mode. But I am not able to receive those notification when the application is in background mode. Is it possible to receive those notification in background mode? Or is there any other way to calculate total unlocked time for a device from my app even when the application is in background mode?
As explained here. Background mode can only be used for specific purposes. If your App is not using background mode for any of those purposes (which it isn't), it will not work.
In short, it could only work on a jailbroken device.
I've developed Android app which has a background service in the sleep mode. This service works with accelerometer data and can launch the app from the sleep mode over the lock screen.
Is it possible to make the same on iOS?
I mean:
Create a service which can work in background with accelerometer data.
Service can launch the app when the phone is in the sleep mode over lock screen. (without unlocking)
If I'm not mistaken it must be possible on iOS7, isn't it?
Thanks!
Yes – Apple publicly stated background processing at WWDC keynote and it can be done to a degree on iOS6
No – Apple will 'probably' never allow an app to be opened without the user instigating it and certainly not over the lock screen.
You could use Push / Local Notifications which do appear on the lock screen to try and entice a user at a specific time to launch the app but no guarantees.
My app is running in background mode because I'm playing and recording audio. I wish to find the device orientation while I'm recording. I set up notification that tells me when the orientation changes and it works fine while the app is active on screen.
My problem is that when I'm moving to background mode the notifications stop coming.
Is there a way to keep getting these notifications while my app is in background mode?
Thanks in advance.
You can check device orientation when your app resumes from background. UIApplicationDelegate protocol has several methods for handling app's transition from background to foreground; check this answer for nice writeup.
I have an external accessory. It seems like it disconnects when the application goes to the background. Is there any way to fix that?
In your application plist file add following flag
"Required background modes" = "App communicates with an accessory"
This solution works only for iOS 5 and grater version.
If the External Accessory background mode string has not been added in the Info.plist, the app will not get any background running time. (See the iOS App Programming Guide)
If the background mode item is added, you can respond to incoming bytes of a connected accessory.
No timer is available in background mode. They would just not fire when timing out. So you need to figure out what is needed and send requests from MFi device to the iOS if you need polling.