检测是否在钛工作室中激活了GPS

时间:2016-06-29 20:30:21

标签: android ios gps geolocation titanium

如何在Android和IOS中检测GPS是否已激活?

def cli():
    print "Welcome. What do you want to do?"
    choice = click.prompt('')
    if choice == 'add':
        add()
        cli()
    else:
        subtract()

我试过这个但是在Android上返回的总是tru,而在IOS上它接缝无所事事。

如何在Android和IOS中检测钛的GPS状态?

1 个答案:

答案 0 :(得分:0)

在iOS中,应用程序启动时会向用户询问GPS权限。您可以添加以下代码ti.xml,并在iOS中为您启用GPS,直到用户从设置中明确禁用此权限。 这是在ti.xml中添加的代码

 <ti:app>
    <ios>
        <plist>
            <dict>
                <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>
            </dict>
        </plist>
    </ios>
</ti:app>
相关问题