[英]Location alert on ios
您可能需要將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.