繁体   English   中英

iOS上的位置提醒

[英]Location alert on ios

我在使用ionic创建的iOS上的应用存在问题。 在我的主菜单中,当我按下一个按钮时,我的应用尝试获取我的位置,并且向我显示了两个警报:一个是意大利语(正确),另一个是英语:

ITA:

意大利警报

英语:

英文警报

第二个警报是如此丑陋。 我希望警报为:“ MYAPP vuole usare la tua posizione”。 如何更改第二个警报的文本?

您可能需要将Cordova位置请求ionicPlatform.ready在控制器中的ionicPlatform.ready

.controller("MapController", ["$scope", "$cordovaGeolocation", "$ionicPlatform", function($scope, $cordovaGeolocation, $ionicPlatform) {

      $ionicPlatform.ready( function() {

            $cordovaGeolocation
              .getCurrentPosition()
              .then(function (position) {
                // do something
                }
              }, function(err) {
                // error
              });

      })

}])

您需要知道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
              });

如果您担心外观,可以尝试使用自定义提醒(如甜蜜提醒)。 http://t4t5.github.io/sweetalert/

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">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM