Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-20604

iOS: ti.geofence not tracking location on

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.1.0
    • Component/s: iOS
    • Labels:
    • Environment:

      ti.geofence 1.1.4
      ti.cloudpush 3.4.1
      ti.map 2.3.6
      appcelerator studio 4.5.0.201602170821
      sdk 5.2.0GA

    • Sprint:
      2018 Sprint 05 SDK, 2018 Sprint 04 SDK

      Description

      on iOS I am setting a location for geofencing. The code and output are below. On the iOS simulator, i set my location to the exact location of the geofence:

      {"latitude":26.2465067,"longitude":-98.2226709}

      then to :

      {"latitude":25.2465067,"longitude":-98.2226709}

      then back to :

      {"latitude":26.2465067,"longitude":-98.2226709}

      none of the events are logged

          var geoFences = e.geo_fences;
          var regionList = [ ];
          for ( var i = 0; i < geoFences.length; i++ ) {
            var fence = geoFences[ i ];
            var loc = fence.loc;
            var MILES_TO_METERS = 1609.34;
            var RAD_TO_MILES = 3959;
            var radius = 400; //parseFloat(loc.radius.replace(/\/[0-9]+/, "")) * MILES_TO_METERS;
            var coordinates = {
                latitude: loc.coordinates[ 1 ],
                longitude: loc.coordinates[ 0 ]
             };
            var region = Geofence.createRegion( {
              center: coordinates,
              radius: radius,
              identifier: "test", //fence.payload.title
            } );
            Ti.API.info( 'Radius (m): ' + radius );
            Ti.API.info( 'Coords (m): ' + JSON.stringify(coordinates) );
            regionList.push( region );
          };
          // Start monitoring for region entrances/exits:
          Geofence.stopMonitoringAllRegions();
          if (regionList.length > 0) {
      	    Geofence.startMonitoringForRegions( regionList );
          }
          Ti.API.info( JSON.stringify( e.geo_fences ) );
          Ti.API.info( e.geo_fences.length );
          Ti.API.info(regionList.length);
          Ti.API.info('regions: ' + Geofence.getMonitoredRegions( ).length);
       
          // Event listener invoked when device enters a region being monitored:
          Geofence.addEventListener( "error", function( e ) {
          	TI.API.info('geo error: ' + JSON.stringify(e));
          });
          Geofence.addEventListener('monitorregions', function(e) {
      	    // Triggered when new regions are added to be monitored
      	    Ti.API.info('####### monitorregion #######: ' + JSON.stringify(e));
      	    for (var i = 0, j = e.regions.length; i < j; i++) {
      	        Ti.API.info('Region id: ' + e.regions[i].identifier);
      	    }
      	});
          Geofence.addEventListener( "enterregion", function( e ) {
            // Display local notification
            Ti.API.info('entered');
          } );
      

      OUTPUT:

      [INFO] : Radius (m): 400
      [INFO] : Coords (m):

      {"latitude":26.2465067,"longitude":-98.2226709}

      [INFO] : [{"id":"56ce0e26c6f20d3509b8c1a4","loc":

      {"radius":".25/3959","coordinates":[-98.2226709,26.2465067]}

      ,"payload":{"alert":"You have a new high score.","icon":"little_star","badge":3,"title":"High score alert!","vibrate":true,"custom_field":{"score":51,"headlines":"And now for something completely different..."}},"created_at":"2016-02-24T20:10:14+0000","updated_at":"2016-02-24T20:10:14+0000"}]
      [INFO] : 1
      [INFO] : 1
      [INFO] : regions: 1
      [INFO] : ####### monitorregion #######: {"regions":[{}],"bubbles":true,"type":"monitorregions","source":

      {"id":"ti.geofence"}

      ,"cancelBubble":false}
      [INFO] : Region id: test

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              macdabby dan
              Reviewer:
              Vijay Singh
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-7076
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code