App that works as iBeacon. How to be discovered even with the app has terminated? - ios

I'm trying to use iBeacon in background mode and works fine, but I want that the app works when has been terminated by the system. It's possible to do this?
Thanks!

It is possible to write your app so it launches into the background when LocationServices sees an iBeacon, even if your app is terminated. See my answer here: https://stackoverflow.com/a/19128781/1461050

It should just work, unless the user removes the app. It's not the app itself that shows the beacon, it is the operating system showing the beacon on behalf of the app. That doesn't change when the OS terminates the app, only if the user does it.

Related

How to deliver a BLE message to an iOS app that isn’t running?

I am working on a device that sends a message/signal to an iOS app via BLE. It currently works fine if the app is running in the foreground or background; however, I need the device to deliver this signal to the app when it isn’t running so it can process it, in essence, “waking it up.”
A device that seems to be doing this well is Tile (used to keep track of keys, etc.). The Tile can signal the phone even when the Tile app isn’t running, making the Tile app come up and sound an alarm. My use case isn’t the same, but I need to achieve the same behavior.
Does anyone have any pointers as to how to achieve this? The OS needs to launch/wake the app upon receiving this BLE message/signal from my device.

How Do i relaunch my iOS app from Kill state for long task?

First i will explain what i want to achieve.
I have a BLE lock. i want that my application will wake up from kill state and start scanning BLE device. Once the BLE device found it will connect with my phone and get unlock.
All this is working in background mode and i tested this many times. but i also want this to be work when app is in kill state.
I tried several things. First I tried Geofencing but in case of geofencing app wake up for less time i'm not properly scan the BLE device. When didEnterRegion region: called i sent the local notification and it was working fine. So after that i tried to scan BLE Devices when didEnterRegion region: and also get the notification that scan is started but i think after some time app remove from the background automatically and could not relaunch. So that's why i'm failed to discovered any BLE device.
I also read apple document for Core BlueTooth:
https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
There is mention that how to perform long task like open and close door lock but isn't help me.
Please guide me how to do this when app is in kill state.
Thanks for the help :)
UPDATE:
What i mean from kill state is suspended/ terminated/removed from background. I just want that once user get enter into the region of geofence then app launch in background and scanning for the BLE device started. so after that i want app will stay into the background until door get unlock.
As Paulw11 mentioned, there's no way to relaunch an app in the background once it is terminated/killed by the user. Apple have done this deliberately for security and functionality reasons: if a user deliberately kills an app because it is buggy/faulty, the app should not be able to relaunch itself.
More information can be found here:-
Core Bluetooth Background Processing for iOS Apps
BLE device keep connect with iPhone when application terminate
I hope this helps.
did u try SLC. It wakes up the app after a kill. Then u can run a long running background task for BLE activity.

Bring iOS App to Foreground in WatchKit

I am developing a WatchKit extension for one of my Apps where I really want to have the iPhone App running in the foreground, since it is doing the heavy lifting and is designed to use location services only when active. I know openParentApplication:reply only opens the App in the background (unless it is already active). What I am currently trying out is using a custom URL scheme for my App, and having the App initially open itself from within the handleWatchKitExtension code in the App Delegate. This works perfectly in the Simulator. Unfortunately I did not have this approach ready when I tested my App on real Apple Watches. Does anyone see a problem with this approach to bring the iPhone App to the foreground from the Apple Watch?
On iOS, apps can't bring themselves to the foreground. The best thing you can do is to post a local notification (UILocalNotification, see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html) and invite the user to bring your app to the foreground.
But for your use case, why not just have your phone app use location services in the background?
This is not possible. The Apple Watch Programming Guide states that the app on the iPhone will run in the background if it was not active before.

Can I communicate with a slave BLE even if app is not running?

I am developing an iOS application that communicates with a slave BLE device. I know iOS will allow my app to run in background to communicate with BLE. What my doubt is that is there any way to turn on my app if there is any BLE near by? I mean even if my app is not running can I communicate with BLE? Like location service works,i.e., if the app registered for a significant location change alert then app will get automatically turned on when there is a significant location change even if app is not running.
I have searched a lot, but couldn't find any helpful documentation. Any help is greatly appreciated..
There are a few things here and I think you have to be careful with terminology. Let's first clarify "Not running". The app has 5 modes it can be in:
Foreground: the app is "live" and on the screen
Background - unlocked: the app is "live" but not on the screen. There is either another app on the screen (front) or possibly the user is on the home screen, browsing his/her apps, etc..
Background - locked: self explanatory
Terminated by user - still on device: The user has double clicked the home button and flicked your app up (iOS7) to close it.
Terminated by system - still on device: The app has been terminated by OS because of memory pressure (other apps needed the memory space).
Obviously, if the user has deleted the app from the device then there is nothing to discuss.
In option 4, the app is still on the device but will not relaunch any of its background services (BLE, location updates, etc..) until the user relaunches the app. This is new iOS7 behavior. If the user terminated the app then he/she does not want it running.
In option 5, because the user has not terminated the app; the OS will relaunch the app background services as it receives callbacks.
In order for an app to run in the background, it requires that you add the appropriate background modes to its plist or simply click on project (top left) and go to "Capabilities" and enable "Background modes" and the appropriate background mode. In your case: "Uses Bluetooth LE Accessories".
Now you seem to be looking for "Scanning" versus connecting and exchanging data and in my experience, scanning will only work in scenarios 1 and 2 and 5. Not 3. I have tried many times to get scanning to happen while phone is locked with no luck.
Now the way, fitbit etc... work in the background is that the app, scans, discovers services and characteristics and "setup updates" between the phone and accessory while the app is in the foreground. Once this setup is done, the "value of interest" updates (heart beat, etc..) can happen between the BLE acessory and the iOS device, in the background (locked and unlocked).
Hope this helps.

Geo Notification on app that is off

Geo Fencing is praised by many, yet I could not easily find an answer to the following.
iOS and/or Android, does an inactive app send you notifications if you are close by?
My question is probably more like: is there an underlying system that knows your app needs to check for your location against the in-app locations and does so despite the app not being active.
Forget the settings where you can switch off geolocation for particular apps, let's assume that is switched on.
But let's assume I just switched my iphone on, no app is running yet. So I am carrying that sleeping phone in my pocket. Would I receive location notifications?
I am currently testing this with Highlight, but maybe someone knows the code/tech side to this answer.
Varies by OS.
On Android, apps can run as a service that are automatically started when the phone boots up. In this case, the user does not need to start the app. So, on Android, yes you would receive location notifications in sleep mode. See http://developer.android.com/guide/components/services.html or https://stackoverflow.com/questions/9866970/tutorial-for-android-services for more info on Android Services.
On Apple, I'm not so sure about running apps as a service like Android. However, I believe there are events that apps in the background can register for. So again, the app (once started) would receive notifications in sleep mode.

Resources