Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple reject app with backrground modes #37

Open
boardmain opened this issue May 28, 2015 · 11 comments
Open

Apple reject app with backrground modes #37

boardmain opened this issue May 28, 2015 · 11 comments

Comments

@boardmain
Copy link

hi i tried to submit one apps with this background modes in the tiapp.xml
but apple rejected it beacouse it use bacground location and bluetooth modes..

how you made to make it approve?

@williamrijksen
Copy link
Contributor

@boardmain I think you don't need the background-modes in the tiapp.xml. If you'll get out the app (by pressing the homebutton or killing the app) while you where monitoring regions, iOS continues monitoring in background automatically. If iOS detects a new beacon in the background, the application will launch and you can get start beaconRanging for 10 seconds.

More information / source : https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html.

@williamrijksen
Copy link
Contributor

@jbeuckm I think it's necessary to update the README about scanning iBeacons when the application is not in foreground. The readme tells it's necessary to define the UIBackgroundModes in tiapp.xml, but Apple has another vision about that (see link above). What do you think?

@wallanoo
Copy link

Hi

can you please show a little example on how to scan iBeacons in background (ranging?)

I'm trying on ios 9 and I cannot range in background

thanks for all in advance

@appinlet
Copy link

First step, include permissions inside your tiapp.xml

For example:

8.0


UIBackgroundModes

location
bluetooth-central
bluetooth-peripheral

NSLocationUsageDescription
This app requests your location to determine the closest event to you, and for generating dynamic iBeacon notifications.
NSLocationAlwaysUsageDescription
This app requests your location to determine the closest event to you, and for generating dynamic iBeacon notifications.
NSLocationWhenInUseUsageDescription
This app requests your location to determine the closest event to you, and for generating dynamic iBeacon notifications.


@appinlet
Copy link

Also, event listeners setup after the correct permissions have been set will still work even when the app has been sent to the background. Only transmitting won't work. It is not required to setup or register a background service in the usual titanium way.

@wallanoo
Copy link

wallanoo commented Mar 1, 2016

Hi, I'm still here, sorry..

I've coded this, in order to notify (app in background) when my iphone enters a region and , second, when it is "near" to beacon.

Region listeners work well, also without UIBackgroundModes,

Proximity listener (or ranging listener, I've tryed also this listener) does not work, also after setting the tiapp.xml correctly as RBAtkins0n suggests.

Here's the code:

var TiBeacons = require('org.beuckman.tibeacons');

TiBeacons.startMonitoringForRegion({
uuid : MYUUID,
identifier : "Test Maverick-Beacon",
});
TiBeacons.startRangingForBeacons({
identifier : 'Region by UUID only',
uuid : MYUUID
});
TiBeacons.addEventListener("enteredRegion", function(e) {
notify("entering region");
});
TiBeacons.addEventListener("exitedRegion", function(e) {
notify("exiting region");
});
TiBeacons.addEventListener("beaconProximity", function(e) {
notify("beacon " + e.major + "/" + e.minor + " is now " + e.proximity);
});

function notify(msg) {
var notification = Ti.App.iOS.scheduleLocalNotification({
alertBody : msg,
alertAction : "OK",
userInfo : {
"hello" : "world"
},
date : new Date(new Date().getTime() + 5) // 5 milliseconds after being asked
});
}

Furthermore: the title of the issue is "Apple reject app with backrground modes" and williamrijksen says that "you don't need the background-modes in the tiapp.xml", so what do I have to do?
Do I miss something?

I'm working with 0.9.3 version of the module, do I have to update to 0.10.0 to work on iOS9?

thanks for all your time, sincerely

@appinlet
Copy link

appinlet commented Mar 1, 2016

iOS 9 is working at present in my current project. Apple will reject you app when you submit it to the app store if you can't justify the benefit to the user for ranging. I've got it working on my project,

(https://community.estimote.com/hc/en-us/articles/203914068-Is-it-possible-to-use-beacon-ranging-in-the-background-)

Firstly, I'm using a branch version 0.11.0 for a number of reasons. Yours may work without the fixes in version 0.11.0, but just letting you know. See https://github.com/williamrijksen/TiBeacons

You need background modes enabled to allow for region events and for ranging. This is how I managed to get it to range in the background, defined in my main js file:

`// REGION EVENTS
function enterRegion(e) {
TiBeacons.startRangingForBeacons(e);
Ti.API.info('Entered ' + e.identifier + ' region');
}

function exitRegion(e) {
TiBeacons.stopRangingForBeacons(e);
Ti.API.info('Exited ' + e.identifier + ' region');
}`

The enter and exit region events trigger the ranging functionality.

@wallanoo
Copy link

wallanoo commented Mar 1, 2016

ok, thanks

I've tried your code, but in this way ranging is performed only for few seconds after the iphone enters the region.
It is possible to perform continuous background ranging?

@williamrijksen
Copy link
Contributor

@wallanoo Continuous background ranging for beacons is only possible when you enable UIBackgroundModes location in the tiapp.xml. When you're only using the monitoring-functionality you should remove the location-key from UIBackgroundModes, otherwise it will be result in a rejection by Apple.

You have to explain to Apple why it's required from a functional perspective to range the beacons also in background-mode. When it's not required from a functional perspective, your app should be rejected by Apple.

I hope it is clear now.

@appinlet
Copy link

appinlet commented Mar 1, 2016

Yes, @williamrijksen is right (and also the author of the branch I'm using).

My project ranges constantly in the background when the beacon is in the region. You don't want to be ranging when outside the beacon, as it uses much more power. I use beaconranges instead of proximity events. Also, I ended up creating a background service that uses determinedRegionState to start ranging if the device in already inside a region (as the enter/exit region event won't fire if the device is already inside the region). If you are ranging and from the foreground and go to background, the ranging will stop, but can be triggered again by either entering/exiting an ibeacon region or by using an event listener in a dedicated background service, at least that's what I did.

@wallanoo
Copy link

wallanoo commented Mar 1, 2016

how do you manage determinedRegionState?

the background service now works for me but only for about 2-3 minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants