簡體   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