我正在嘗試使用 webview 訪問我網站上的網頁。該網頁嵌入了谷歌地圖。從瀏覽器打開此頁面時,地圖顯示正確。但是當從 Xamarin Forms Android 應用程式(iOS 我還沒有嘗試過)打開時,它在日志中顯示以下錯誤:
[chromium] [INFO:CONSOLE(627)] "Permission denied", source: <url of my website page that has the map>
正如關于 SO 的其他問題所建議的那樣,我添加了以下網路組態檔:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">mysite.com</domain>
<domain includeSubdomains="true">mysite.co.nz</domain>
<!-- Debug port -->
<domain includeSubdomains="true">google.com</domain>
<domain includeSubdomains="true">googleapis.com</domain>
<domain includeSubdomains="true">maps.googleapis.com</domain>
</domain-config>
</network-security-config>
并在清單中添加:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:networkSecurityConfig="@xml/network_security_config" .............
另外,我添加了權限:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
另外,我添加了Xamarin.GooglePlayServices.Maps包。
但是沒有一個解決方案有效。請幫忙。
uj5u.com熱心網友回復:
它在哪里顯示或請求使用 GPS 的訪問權限?用戶必須接受使用其 GPS 進行的跟蹤。您應該始終檢查用戶是否批準該權限,僅添加清單是不夠的,因為如果用戶在應用串列中導航,他可以取消選中此權限,然后您的應用將無法運行甚至崩潰。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/496051.html
