Angularjs Ionic应用程序在iOS上未检测到iBeacons(cordova plugin estimote)

Angularjs Ionic应用程序在iOS上未检测到iBeacons(cordova plugin estimote),angularjs,cordova,ionic-framework,ibeacon,estimote,Angularjs,Cordova,Ionic Framework,Ibeacon,Estimote,我目前正在开发一个混合应用程序(Ionic),在iOS上检测iBeacons时遇到问题(目前在9.2上开发)。我正在使用cordova插件estimote()来检测信标,遵循他们的文档,一切都可以在Android上正常工作,但在iOS上不行。信标根本没有被检测到。没有错误,只是找不到任何东西。 有趣的事实:当我在iPhone上下载最初的estimote应用程序时,它也没有检测到任何iBeacons,直到我登录。之后,它开始正常检测它们。为什么会这样 基于插件文档的我的AngularJS代码的相关


我目前正在开发一个混合应用程序(Ionic),在iOS上检测iBeacons时遇到问题(目前在9.2上开发)。我正在使用cordova插件estimote()来检测信标,遵循他们的文档,一切都可以在Android上正常工作,但在iOS上不行。信标根本没有被检测到。没有错误,只是找不到任何东西。

有趣的事实:当我在iPhone上下载最初的estimote应用程序时,它也没有检测到任何iBeacons,直到我登录。之后,它开始正常检测它们。为什么会这样

基于插件文档的我的AngularJS代码的相关部分:

$scope.init = function() {
  bluetoothSerial.isEnabled(scanBeacons, errorBluetooth);
}

function scanBeacons() {
  startScanning();
  updateList = $interval(updateView, 5000);
}

function startScanning() {
  console.log("requesting permissions");
  estimote.beacons.requestAlwaysAuthorization(successAuth, errorAuth);
}

function successAuth(){
  console.log("success auth, starting scan");
    estimote.beacons.startRangingBeaconsInRegion(
      {},
      onMonitoringSuccess,
      onError);
}

function errorAuth(){
  console.log("error auth");
  popupService.showPopup("Authorization error", "Location services required to perform scanning");
}

function onMonitoringSuccess(regionState) {
  console.log("monitoring success: "+JSON.stringify(regionState));
  var successHandler = function (response) {
    $scope.downloadedlist = response;
    $scope.offline = false;
  };
  var errorHandler = function (response) {
    $scope.beaconList = regionState.beacons;
  };
  eventService.getBeaconList(regionState.beacons, storageService.getEventId())
    .then(successHandler)
    .catch(errorHandler);
}

function onError(response) {
  console.log("monitoring error: "+JSON.stringify(response));
  popupService.showPopup('popup.error.title', 'popup.error.server');
}
如您所见,我有一些console.log语句(必须这样做),我得到了“请求权限”,紧接着是“successauth,startingscan”。这很奇怪,因为会显示授权弹出窗口,但代码不会等待用户输入,它只会自动启动成功处理程序(successAuth)函数,就是这样。没有更多的日志,这意味着没有监控成功,没有错误,只是找不到任何信标


谢谢你的帮助。谢谢。

终于找到了解决方案。问题就在这里:

estimote.beacons.startRangingBeaconsInRegion(
  {},
  onMonitoringSuccess,
  onError);
结果表明,Android允许在下面的函数中使用{}参数(这意味着查找所有区域),但iOS不允许。指定区域后,我的应用程序成功地找到了信标

例如:

function successAuth(){
 console.log("success auth, starting scan");
 var region = { uuid: 'YOUR_UUID_HERE' }
 estimote.beacons.startRangingBeaconsInRegion(
  region,
  onMonitoringSuccess,
  onError);
}
Estimote开发商报价:

iOS只允许扫描UUID为您所知的信标。所有Estimote信标都附带我们的默认UUID,“B9407F30-F5F8-466E-AFF9-25556B57FE6D”,这些信标即使未登录也可以在雷达上看到。如果您将此UUID更改为其他内容,则需要保持登录状态,以便Estimote应用程序可以知道您的信标的UUID是什么,并在默认UUID之外扫描它们

资料来源:

这也解释了为什么Estimote应用程序在登录后开始检测iBeacons