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

iOS has a limite Beacon Region Monitoring? #447

Open
eduboxgithub opened this issue Oct 21, 2020 · 0 comments
Open

iOS has a limite Beacon Region Monitoring? #447

eduboxgithub opened this issue Oct 21, 2020 · 0 comments

Comments

@eduboxgithub
Copy link

I'm trying to implement a beacon feature in a app. I have a total of 80 Beacons.

I currently loading a json file that has all the beacons setup info.
Then, in the code, after the json is loaded, I create a BeaconRegion and add it to an array:

var beaconRegions = [];

jsonBeacons.forEach(beacon => {
      beaconRegions.push(new cordova.plugins.locationManager.BeaconRegion(item.identifier, item.uuid, major, minor));
})

After all the Beacons Objects have been created I add them to the plugin motoring service:

beaconsRegions.forEach(beacon => {
      cordova.plugins.locationManager.startMonitoringForRegion(beacon)
      .fail(function(e) { 
           console.log("error add beacon: " + e); 
      })
      .done(function (e) {
           console.log("add beacons: " + e);
      });
});

This seems to work on Android... All beacons are successfully added and the motoring starts, ate least some of the 80 beacons were testes and the events onExit e onEnter are fired.

But when the app is run on iOS, the beacons are added, but no events are fired. We made some tests, and added beacons in increments, a group of 5, a group of 10, a group of 15, just for example... and it seems that if we try to add more than 14/15 beacons, then, no events are fired.

The full code is below:

var startListeningBeacons = function ()
{
	delegate = new cordova.plugins.locationManager.Delegate();

	delegate.didDetermineStateForRegion = function (pluginResult)
	{
		console.log('Event didDetermineStateForRegion: ' + JSON.stringify(pluginResult));

		cordova.plugins.locationManager.appendToDeviceLog('Event didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
	};

	delegate.didStartMonitoringForRegion = function (pluginResult)
	{
		console.log('Event didStartMonitoringForRegion:', pluginResult);

		console.log('Event didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
	};

	delegate.didRangeBeaconsInRegion = function (pluginResult)
	{
		console.log('Event didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
	};

	delegate.didEnterRegion = function (pluginResult)
	{
		//DO SOMETHING WITH THE BEACON INFO
		//callNotificationPush(pluginResult, 1);

		console.log('Event didEnterRegion: ' + JSON.stringify(pluginResult));
	};

	delegate.didExitRegion = function (pluginResult)
	{
		//DO SOMETHING WITH THE BEACON INFO
		//callNotificationPush(pluginResult, 2);

		console.log('Event didExitRegion: ' + JSON.stringify(pluginResult));
	};

	createBeacons().then(function()
	{
		cordova.plugins.locationManager.setDelegate(delegate);

		cordova.plugins.locationManager.requestAlwaysAuthorization();

		console.log("Mono");
	});
};

var createBeacons = function ()
{
	console.log("ENTROU NO CREATE BEACONS");

	var beaconsDataLength = beaconsData.length;

	var arrayBeacons = [];

	var counterFail = 0;

	var counterDone = 0;

	return new Promise(function (resolve, reject)
	{
		for (i = 0; i < beaconsDataLength; i++) 
		{
			if (checkUUIDBeacon(beaconsData[i].UUID))
			{
				try
				{
					var beaconRegion = new cordova.plugins.locationManager.BeaconRegion
					(
						beaconsData[i].Identifier,
						beaconsData[i].UUID,
						beaconsData[i].Major,
						beaconsData[i].Minor,
						beaconsData[i].notifyEntryStateOnDisplay
					);

					arrayBeacons.push(beaconRegion);
				} 
				catch (error)
				{
					console.log("error create beacon", error);
				}
			} 
			else
			{
				console.log("NAME: " + beaconsData[i].Identifier + "UUID: " + beaconsData[i].UUID)
			}
		}

		var arrayBeaconsLength = arrayBeacons.length;

		for (var j = 0; j < arrayBeaconsLength; j++)
		{
			var beacon = arrayBeacons[j];

			cordova.plugins.locationManager.startMonitoringForRegion(beacon)
			.fail(function (e)
			{
				console.log("error add beacon: " + e);

				++counterFail;

				checkAsyncAddBeaconsComplete(counterFail, counterDone, arrayBeaconsLength, resolve);
			})
			.done(function (e)
			{
				console.log("added beacon: " + e);

				++counterDone;

				checkAsyncAddBeaconsComplete(counterFail, counterDone, arrayBeaconsLength, resolve);
			});
		}
	});
};

var checkUUIDBeacon = function (uuid)
{
	var regex = new RegExp(/^[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}$/i);

	return regex.test(uuid);
}

var checkAsyncAddBeaconsComplete = function (countFail, countDone, countTotal, callback)
{
	if ((countFail + countDone) == countTotal)
	{
		callback();

		console.log("All beacons with no errors as been added.");
	}
}
  1. Expected behavior and actual behavior.
    Add 80 beacons all get events from all the beacons. Actually on iOS it seems there's some king of limite to the total number of beacons that are monitored.

  2. Steps to reproduce the problem.
    Add a bunch of beacons. If we only add one (1, 2, 3... maybe 13/14 at max) it works on Android and iOS with the same code base.

  3. cordova-android version
    Cordova 8.1.2 and Android 8.1.0

  4. cordova-ios version
    Cordova 8.1.2 and and iOS 5.0.1

  5. cordova-plugin-ibeacon version
    3.8.1

  6. If running on a device, device model and os version.
    iPhone SE 2nd (ios 14 updated)

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

1 participant