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

iOS: BgService more than 10 minutes and show blue bar issue for Location.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Environment:
    • Story Points:
      3

      Description

      Steps to Reproduce.

      1. Create a classic project.
      2. paste the following code to the corresponding file.

      app.js

      var win = Ti.UI.createWindow({
      	title : 'Background Services Example',
      	backgroundColor : '#4186cd',
      	modal : true
      });
       
      // Create a Button.
      var bgService = Ti.UI.createButton({
      	title : 'StartService',
      	height : Ti.UI.SIZE,
      	width : Ti.UI.SIZE,
      	top : 20,
       
      });
       
       
      function bgServiceStart() {
      	Ti.API.info('Registering background services');
      	var service = Ti.App.iOS.registerBackgroundService({
      		url : 'bgservice.js'
      	});
      	Ti.API.info('*** Press home button to pause application ***');
      }
       
      // Listen for click events.
      bgService.addEventListener('click', function() {
      	bgServiceStart();
       
      	alert('click bg service');
      });
       
      // Add to the parent view.
      win.add(bgService);
       
      win.open();
       
      
      

      bgservice.js

      Ti.API.info('bg-service1: service page');
       
      if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
      	Ti.App.iOS.registerUserNotificationSettings({
      		types : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE]
      	});
      }
       
      function pushData(latLong) {
       
      	var curNotif = Ti.App.iOS.scheduleLocalNotification({
      		alertBody : latLong,
      		date : new Date(new Date().getTime() + 1000)
      	});
      }
       
      function getCoords() {
       
      	if (Ti.Geolocation.locationServicesEnabled) {
      		Ti.Geolocation.allowsBackgroundLocationUpdates = true;
      		Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
      		Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;
      		Ti.Geolocation.addEventListener('location', function(e) {
      			if (e.error) {
      				alert('Error: ' + e.error);
      			} else {
      				Ti.API.info("value=" + e.coords);
      				pushData(e.coords.latitude + '\n' + e.coords.longitude);
      			}
      		});
      	}
       
      }
       
      setInterval(function() {
      	getCoords();
       
      }, 10000);
      
      

      tiapp.xml

      <key>UIBackgroundModes</key>
      <array>
      <string>location</string>
      </array>
      <key>NSLocationAlwaysUsageDescription</key>
      <string>Specify the reason for accessing the user's location information.
      This appears in the alert dialog when asking the user for permission to
      access their location.</string>
      <key>UISupportedInterfaceOrientations~iphone</key>
      

      3. Run that code to the device
      4. It does not work more that 10 minutes even below 10 minutes and don't show blue bar.
      5. It should work more that 10 minutes and show blue bar as well since I have added UIBackgroundModes key

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              morahman Motiur Rahman
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration