cordova.plugins.locationAccuracy.request>继续提示启用位置服务

时间:2018-11-27 08:28:52

标签: cordova-plugins

我有以下https://github.com/dpa99c/cordova-plugin-request-location-accuracy中的科尔多瓦代码。 问题是为什么即使我选择了“否”,它仍然提示我启用定位服务。有任何线索吗?

_makeRequest: function() {
            cordova.plugins.diagnostic.isLocationEnabled(function(enabled) {
                if (!enabled) {
                    var platform = cordova.platformId;
                    console.log('platform: ' + platform);

                    cordova.plugins.locationAccuracy.canRequest(function(canRequest) {
                        if (canRequest) {

                            cordova.plugins.locationAccuracy.request(function() {
                                    console.log("Location accuracy request successful");
                                }, function(error) {
                                    console.log("Error requesting location accuracy: " + JSON.stringify(error));
                                    if (error) {

                                        console.log("error code=" + error.code + "; error message=" + error.message);
                                        console.log(error);
                                        if (error.code === cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED) {
                                            console.log("YEEE");
                                        }

                                        if (error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED) {
                                            if (window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")) {
                                                cordova.plugins.diagnostic.switchToLocationSettings();
                                            }
                                        }
                                    }
                                }, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY // iOS will ignore this
                            );

                        } else {
                            // On iOS, this will occur if Location Services is currently on OR a request is currently in progress.
                            // On Android, this will occur if the app doesn't have authorization to use location.
                            console.log("Cannot request location accuracy");
                        }
                    });
                }
            });
        },

0 个答案:

没有答案