0

ユーザーの現在の場所に最も近い製品ディーラーをリストするアプリを作成しています。

デバイス iPhone 6 および iPhone 4S でテストすると、アプリに位置情報を取得する権限がないことがわかりますが、設定に移動すると、その権限を付与するテスト アプリが一覧表示されません。

これは、Appcelerator Studio を介して「実行」したときにアプリがインストールされる方法によるものですか? テストアプリに許可を与えるにはどうすればよいですか?

私のコードは次のとおりです。

function getCurrentPhoneLocation(callback)
{
    Titanium.API.info("get phone location " + Ti.Geolocation.locationServicesEnabled);
    if(Ti.Geolocation.locationServicesEnabled)
    {
        Titanium.API.info("GPS permissions: " + Ti.Geolocation.locationServicesAuthorization + " (" + Ti.Geolocation.AUTHORIZATION_ALWAYS + " | " + Ti.Geolocation.AUTHORIZATION_AUTHORIZED + " | " + Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE +  ")");
        if (Ti.Geolocation.locationServicesAuthorization == Ti.Geolocation.AUTHORIZATION_ALWAYS || Ti.Geolocation.locationServicesAuthorization == Ti.Geolocation.AUTHORIZATION_AUTHORIZED || Ti.Geolocation.locationServicesAuthorization == Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE)
        {
              Titanium.API.info("Got permissions - lets go!");

              Ti.Geolocation.purpose = 'Get current location';        

              var currentPhoneLocation = {};

              Ti.Geolocation.getCurrentPosition(function(e){
                  Titanium.API.info("from pos: " + JSON.stringify(e));
                  if(e.success === false) {
                      Ti.API.error('Error:' + e.error);
                      alert("Location is currently unavailable");
                      callback( false );
                  } else {

                      currentPhoneLocation.longitude = e.coords.longitude;
                      currentPhoneLocation.latitude = e.coords.latitude;
                      Ti.API.info("Returned Cords: " + JSON.stringify(currentPhoneLocation));
                      callback(); 
                  }               
              });             
        } 
        else
        {
              Titanium.API.info("No APP permission");
              Titanium.UI.createAlertDialog({title:'Location Service', message:'Please grant this app permission to get your location.'}).show();
              callback( false );
        }
    }
    else
    {
          Titanium.API.info("No GPS available");
          Titanium.UI.createAlertDialog({title:'Location Service', message:'Please turn on your location services.'}).show();
          callback( false );
    }
}

私のトレース コードは、Ti.Geolocation.locationServicesAuthorization が「0」を返していることを示していることがわかります。

[INFO] :   get phone location true
[INFO] :   GPS permissions: 0 (3 | 3 | 4)
[INFO] :   No APP permission
[INFO] :   Recieved location: false
4

1 に答える 1