首页 > 解决方案 > Nativescript Vue.js 定位 GPS

问题描述

我最近使用原生 vue.js 开发了一个 Android 应用程序。

我使用了地理定位插件,它可以在具有 google play 服务的设备上完美运行,但不能在禁用 Google 服务的设备上运行。

我正在寻找一个可以在没有 Google 服务的设备上进行定位的模块。

需要你的帮助。

标签: javascriptvue.jsnativescript

解决方案


尝试这个,

import * as application from "application";

const PLAY_SERVICES_RESOLUTION_REQUEST = 9999;

...
isGooglePlayServicesAvailable() {
        const googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance();
        const resultCode = googleApiAvailability.isGooglePlayServicesAvailable(application.android.context);
        if (resultCode != com.google.android.gms.common.ConnectionResult.SUCCESS) {
            if (googleApiAvailability.isUserResolvableError(resultCode)) {
                apiAvailability.getErrorDialog(application.android.context, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                        .show();
            }
            return false;
        }
        return true;
    }
 ...

如果不可用,它将通知并安装播放服务。


推荐阅读