gpt4 book ai didi

ios - 如何在 Xamarin iOS 应用程序中启用位置服务

转载 作者:行者123 更新时间:2023-11-29 05:40:35 25 4
gpt4 key购买 nike

我想要简单地启用位置服务,我已在 info.plist 文件中添加了以下内容

Generic PList editor

我已启用后台模式和位置​​(ios list 编辑器 View ) enter image description here

但是当我安装应用程序时(从连接的 iPad - IPA 上的 XCode)。该应用程序确实会弹出有关允许通知的通知,但没有有关启用位置服务的消息。

根据 Ricardo 的评论,我已将所需的设置添加到我的 info.plist 文件中。我的 info.plist 文件现在看起来像这样。

Generic XML Editor view.

构建、重新安装 ipa 后,我得到的唯一弹出窗口是允许通知,并且没有允许位置服务的弹出窗口。我错过了什么?

最佳答案

它只询问您何时开始使用位置。或者,您可以强制应用使用 Xamarin.Plugin.Permission 包提示用户权限,然后检查权限并像这样请求它。

        var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
if (status != PermissionStatus.Granted)
{
if(await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
{
await DisplayAlert("Need location", "Gunna need that location", "OK");
}

var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];
}

关于ios - 如何在 Xamarin iOS 应用程序中启用位置服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56598616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com