My application run on iOS 8 and when it go into background it need to detect and show a notification to the user when iBeacon detected (with UILocalNotification).
All works fine but when the iPhone is sleep/locked the Notification doesn't wake up the device.
How can I wake up the device when a notification come in?
Make sure the phone is detecting the beacon at all. Try adding a NSLog statement inside the didEnterRegion method or wherever you launch the notification. Then, start looking at the debug console while the phone screen is off and turn on the beacon. Do you get a debug line?
If you do not see the debug line, the issue is with detection, not with the notification. Note that it can take up to 15 minutes on an iPhone 4S to detect a beacon.
If this does not help, please post your code that sets up region monitoring and sends the notification. Also, please, describe how you are testing entering and exiting the region.
Related
I read in many places that if user swipes up and kills an app, that app will not be able to receive location updates. I get didEnterRegion and didExitRegion callbacks are received when my app is not killed and is in background. But if I swipe kill app, app doesn't get those callbacks. My question here is,
Is it that app will stop getting callbacks ever? i.e., even if the app is launched again and is in background it does not get the callbacks
I read about startMonitoringSignificantLocationChanges and background app refresh when used together, I can get callback even when app is killed by swipe. I tried this and could not get it working. Is this the expected behavior?
Will startMonitoringSignificantLocationChanges and background app refresh together when used, I get region entry/exit callbacks after rebooting device?
This is not expected behavior. You are supposed to get didEnterRegion and didExitRegion callbacks even after killing an app in the task switcher. If you are not seeing this, something may be wrong with your app or testing methodology. Posting code may be helpful.
A few caveats and tips:
Make sure your app has obtained backround permission with locationManager.requestAlwaysAuthorization(). Without it, it cannot detect at all in the background.
Detection in the killed state did not work on iOS 7.0.x. It started working as of 7.1+.
Make sure you wait long enough to get detections. In some app states, it can take up to 15 minutes.
Before killing your app in testing, check logs to ensure you know what CoreLocation thinks is your current region state. If you turn off a beacon then kill your app, CoreLocation may not have had time to realize the beacon disappeared, thinking it is still inside the region. If you then turn on the beacon, you will not get a new entry event because it thinks you are already inside.
I'm interested in a border line iPhone app able to detect the user location continuosly.
The app will be delivered in enterprise mode (so no Apple approval).
Basically it should run forever (resetting the backgroundTimeRemaining through the location service start end stop).
the issue that I was not able to fix is to relaunch the app after a reboot, event if I declare the voip capability, it seems that the system give me only 3 minutes, no more time despite all the workarounds.
so actually I'd like to know if someone was able to implement this sort of behaviour on iOS7.
thanks in advances, please find below some references.
iPhone - Backgrounding to poll for events
to run app continuously in the background
Background Location Services not working in iOS 7
Start Location Manager in iOS 7 from background task
ok, I got it.
the music hack is the solution.
During the further 180s of background time a small mute playback of few seconds (of local mp3) restart the backgroundTimeRemaining counter.
bye
I've integrated opentok ios sdk in my iOS 7 app, it is working fine, except this problem:
During video chat if I don't access iPhone for 5-10 seconds..then my app moves into background, causing viewer at other end to hear only audio. Video is disabled after app goes to background state.
I've observed same thing with their official example
https://github.com/opentok/opentok-ios-sdk/tree/master/samples/OpenTokFullTutorial
How can I avoid my app going to background while video chat is ongoing. Skype is working fine in this case, I want to achieve same thing.
What you want to do is prevent the iPhone from going to sleep. To do this, you cant try this:
[UIApplication sharedApplication].idleTimerDisabled = YES;
Here is iOS documentation on idleTimerDisabled
If you don't want the app going into background at all (like when the user taps on home button), you can opt to kill the app when it's not running instead of having it run in the background. To do that, check out iOS guide on opting out of background execution
If you do not want your app to run in the background at all, you can
explicitly opt out of background by adding the
UIApplicationExitsOnSuspend key (with the value YES) to your app’s
Info.plist file. When an app opts out, it cycles between the
not-running, inactive, and active states and never enters the
background or suspended states. When the user presses the Home button
to quit the app, the applicationWillTerminate: method of the app
delegate is called and the app has approximately 5 seconds to clean up
and exit before it is terminated and moved back to the not-running
state.
Hope that helped!
I want to know if Beacons can launch a simple URL in iOS7 devices when they come into a predefined range of the Beacon or do they need a specially designed BLE enabled application sitting on the phone to do this other than a browser like Safari, Chrome, etc.
Basically I want to understand if BLE and Beacons can act in a similar scenario to tapping a phone on an NFC tag ie user taps NFC device on NFC tag and a simple URL is launched which is loaded in the users default browser.
Appreciate the assistance.
Unfortunately, you cannot do what you are looking to accomplish.
You MUST have your OWN app on a device to detect iBeacon, and trigger an action
If you did have an app on a device, you can do anything you like when you come in range, or leave the range of a known iBeacon.
Yes, this can work.
An iOS app can launch a URL in Safari with:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://www.google.com"]];
As for making the app do this when a Phone taps on an iBeacon, this is possible with some caveats. You would have to combine both the iBeacon monitoring and ranging APIs like this:
The monitoring API would be used to launch the app into the background when an iBeacon is first seen. The app would then bring itself to the foreground and start ranging.
Once ranging says the iBeacon is in "immediate" proximity (about half a meter away), the app would execute the code above to launch Safari with a specific URL.
One caveat is that this solution means the app has to be displaying something in the foreground from the time that your phone first sees the iBeacon (about 100 feet away) and when it is in close enough range for you to launch the URL in Safari. I suppose you could simply show instructions like "tap the nearby iBeacon".
Another caveat is that if the user sends the app to the background during ranging, the app won't be able to perform this functionality again until the user goes out of range of the iBeacon and comes back in range. Otherwise the app will remain suspended.
It would be the application (yours) recognizing that it has come within range of a predefined beacon and then (your app) would launch a UIWebView - still within your app - with a predetermined URL.
Hope this helps.
I'm working on an alarm clock application for iOS 4.x. The other alarm clock applications that I've seen are able to present the user with something other than a local notification (i.e., a custom view) and are able to play a sound file. I've been looking into how that's done and have only found this solution:
Play sound with screen turned off / don't let iPhone go to sleep
Is there another approach or is this the best practice?
When your app is not visible, you can't display anything. The silent sound workaround is a cool trick but when a user presses your home button, your app is not visible (and might get destroyed under certain conditions) -> therefore you can't display anything.
So if you tell your user to use your alarm clock by firing it up and then press the sleep button it will work - you can display anything on your screen after the user unlocks the iphone again.
Needless to say that playing sound (even silent sound files) drains the battery so your user might be disappointed if he's not woken up because his iphone has run out of battery.
And yes, there is best practice: Local Notifications! Beginning with iOS 5 it will display your apps icon next to the notification...