0

私のプロジェクトで重大な問題に直面しています。私はAppceleratorで新しく、私はそれを修正する方法を知らない。このエラーは私のマシンには届いていません。しかし、同じものが私が使用している別のマシンに入っています。未知の型エラー:オブジェクト#<Geolocation>には 'hasLocationPermissions'メソッドがありません

最初のファイル

/** 
* Hepers for run-time permissions. 
*/ 

// DEPENDENCIES 
var dialogs = require('alloy/dialogs'); 

// PUBLIC INTERFACE 
exports.requestLocationPermissions = requestLocationPermissions; 

// PRIVATE FUNCTIONS 
function requestLocationPermissions(authorizationType, callback) { 

    // FIXME: Always returns false on Android 6 
    // https://jira.appcelerator.org/browse/TIMOB-23135 
    if (OS_IOS && !Ti.Geolocation.locationServicesEnabled) { 
     return callback({ 
      success : false, 
      error : 'Location Services Disabled' 
     }); 
    } 

    // Permissions already granted 
    if (Ti.Geolocation.hasLocationPermissions(authorizationType)) { 
     return callback({ 
      success : true 
     }); 
    } 

    // On iOS we can determine why we do not have permission 
    if (OS_IOS) { 

     if (Ti.Geolocation.locationServicesAuthorization === Ti.Geolocation.AUTHORIZATION_RESTRICTED) { 
      return callback({ 
       success : false, 
       error : 'Your device policy does not allow Geolocation' 
      }); 

     } else if (Ti.Geolocation.locationServicesAuthorization === Ti.Geolocation.AUTHORIZATION_DENIED) { 

      dialogs.confirm({ 
       title : 'You denied permission before', 
       message : 'Tap Yes to open the Settings app to restore permissions, then try again.', 
       callback : function() { 
        Ti.Platform.openURL(Ti.App.iOS.applicationOpenSettingsURL); 
       } 
      }); 

      // return success:false without an error since we've informed the user already 
      return callback({ 
       success : false 
      }); 
     } 
    } 

    // Request permission 
    Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) { 

     if (!e.success) { 
      return callback({ 
       success : false, 
       error : e.error || 'Failed to request Location Permissions' 
      }); 
     } else { 
      callback({ 
       success : true 
      }); 
     } 
    }); 
} 

セカンドファイル(私が最初に(ファイル名追加してい:。こっちPermi)を

var Perm = require('Permi'); 

$.window.addEventListener("focus", function(e) { 
    Perm.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) { 
     if (!e.success) { 
      if (e.error) { 
      } 
      return; 
     } else { 
      Titanium.Geolocation.getCurrentPosition(function(e) { 
       if (e.success == false) { 
       } else { 
        longitude = e.coords.longitude; 
        latitude = e.coords.latitude; 

        Titanium.Geolocation.reverseGeocoder(latitude, longitude, function(e) { 
         if (e.success) { 
          var places = e.places; 
          if (places && places.length) { 
           driverCity = places[0].city; 
           driverState = places[0].address; 
           annotation.title = e.places[0].displayAddress; 
          } else { 
          } 
         } 
        }); 

        $.mapview.applyProperties({ 
         mapType : Alloy.Globals.Map.NORMAL_TYPE, 
         region : { 
          latitude : latitude, 
          longitude : longitude, 
          latitudeDelta : 0.05, 
          longitudeDelta : 0.05, 
         }, 
         animate : true, 
         regionFit : true, 
         userLocation : false, 
        }); 

        var annotation = Alloy.Globals.Map.createAnnotation({ 
         latitude : latitude, 
         longitude : longitude, 
         title : "The DEMO", 
         pincolor : Alloy.Globals.Map.ANNOTATION_RED, 
         myid : 1 
        }); 
        $.mapview.addAnnotation(annotation); 
       } 
      }); 
     } 
    }); 
    this.removeEventListener('focus', arg); 
}); 

すべてのヘルプは深く理解されるであろうおかげ

+0

どのシステムで問題が発生していますか? erfrorメッセージは何ですか? –

+0

どのTitanium SDKバージョンをお使いですか? – developer82

+0

問題はMacで発生します。私はTitanium SDK 5.2.2 GAを使用しています – Dev786

答えて

0

を使用してください。 Titanium SDK 5.4.0.GA以降のバージョンには、Android 6の実行時アクセス許可処理に関する大きな変更が含まれているため、詳しくはTi.Android.requestPermissionsを参照してください。

関連する問題