我在使用ionic创建的iOS上的应用有问题。 在我的主菜单中,当我按下按钮时,我的应用程序尝试获取我的位置,它向我显示两个警报: 一个用意大利语(这是正确的)和一个用英语写的:
ITA:
ENGLISH:
第二次警报太难看了。我希望警报将是:“MYAPP vuole usare la tua posizione”。如何更改第二个警报的文本?
答案 0 :(得分:0)
您可能需要将Cordova位置请求包含在控制器中的ionicPlatform.ready
.controller("MapController", ["$scope", "$cordovaGeolocation", "$ionicPlatform", function($scope, $cordovaGeolocation, $ionicPlatform) {
$ionicPlatform.ready( function() {
$cordovaGeolocation
.getCurrentPosition()
.then(function (position) {
// do something
}
}, function(err) {
// error
});
})
}])
答案 1 :(得分:0)
您需要知道Javascript警报和本机警报之间存在差异。
您可以使用cordova notification
插件并在其中显示所需的输出。
您可以从此处获取插件信息: https://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html
从github repo下载插件
代码实现如下:
$cordovaGeolocation
.getCurrentPosition()
.then(function (position) {
//here call the notify method
navigator.notification.alert(message, alertCallback, [title], [buttonName]) // instead of message pass the position
//title it so index.html will not be displaying
}
}, function(err) {
// error
});
答案 2 :(得分:-1)
如果您担心外观,可以尝试使用甜蜜警报等自定义提醒。 built-in function
JS:
var script_0 = document.createElement('script');
script_0.src = "https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.min.js";
document.body.appendChild( script_0 );
var link_0 = document.createElement('link');
link_0.rel = "stylesheet";
link_0.type = "text/css";
link_0.href = "https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.css";
document.body.appendChild( link_0 );
或HTML:
<script src="https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.min.js"> </script>
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.css">