Search code examples
appceleratortitanium-mobileappcelerator-mobiletitanium-modules

Issue in Titanium Appcelerator


I am trying to import a project and run it onto iPhone Simulator on Appcelerator, but I am getting a message on console that says,

 [WARN] :  The Ti.Geolocation.purpose property must be set.
        [INFO] :  {"source":{"cache":false},"type":"error"}

I have spent more than 2 hours on trying to eradicate the issue. Also, Please share useful resources about appcelerator app lifecycle.


Solution

  • It says "The Ti.Geolocation.purpose property must be set." I would try something like

    Ti.Geolocation.purpose = "Find restaurants near you";
    

    iOS want to let the user know why your App wants to know his location. The user must allow this Geolocation permission. Thats why you should surround your location requests with an if-statement:

    if (Titanium.Geolocation.locationServicesEnabled){
        Titanium.Geolocation.getCurrentPosition(function(e){
            Ti.API.info(e.coords);
        }
    }else{
        Titanium.UI.createAlertDialog({title:'Location Service', message:'Please turn on your location services.'}).show();
    }