当前位置: 首页 > news >正文

个人网站建设方案实施朝阳区seo搜索引擎优化介绍

个人网站建设方案实施,朝阳区seo搜索引擎优化介绍,怎样创建网站流程,做石膏选图形的网站Overview 概述 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pgnvehxf-1678717852996)(./blog_cover.png)] Core Location 提供的服务可以确定设备的地理位置、高度和方向,或者它相对于附近 iBeacon 设备的位置。 该框架使用设备上的所…

Overview 概述

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pgnvehxf-1678717852996)(./blog_cover.png)]

Core Location 提供的服务可以确定设备的地理位置、高度和方向,或者它相对于附近 iBeacon 设备的位置。 该框架使用设备上的所有可用组件收集数据,包括 Wi-Fi、GPS、蓝牙、磁力计、气压计和蜂窝硬件。

core class - CLLocationManager 核心类

Declaration 声明

class CLLocationManager : NSObject

Detailed Analysis 详解

是管理应用程序与位置相关的行为的核心类 (central place), 可以借助其 实例对象 来配置、启动和停止位置服务。进而实现如下:

  • Track (跟踪) large or small changes in the user’s current location with a configurable degree of accuracy (准确度/精度).
  • Report heading changes from the onboard compass. (译: 从机载罗盘报告航向变化。)
  • 监视感兴趣的地理区域并在有人进入或离开这些区域时生成事件。
  • Report the range to nearby Bluetooth beacons. (译: 向附近的蓝牙信标报告范围。)

在您的应用程序中创建一个或多个 CLLocationManager 对象,并在需要位置数据的地方使用它们。 创建 CLLocationManager 对象后,对其进行配置,以便 Core Location 知道报告位置更改的频率 (how often to report location changes)。 特别是,使用反映应用需求的值配置 distanceFilterdesiredAccuracy 属性。

Receiving data from location services 数据是怎样传递的 ?

A CLLocationManager object reports all location-related updates to its delegate object, which is an object that conforms to the CLLocationManagerDelegate protocol.

译(zh_CN): CLLocationManager 对象将所有与位置相关的更新报告给它的委托对象,这是一个符合 CLLocationManagerDelegate 协议的对象。

这里有两点需要注意:

⓪. 当 CLLocationManager 对象完成自己的初始化, 会调用代理的locationManagerDidChangeAuthorization(_:)方法上报App的定位权限状态, 所以在配置 CLLocationManager 时要马上指定delegate.

①. delegate方法回调与 CLLocationManager 实例化是同一线程.

官方原文如下

Assign the delegate immediately when you configure your location manager, because the system reports the app’s authorization status to the delegate’s locationManagerDidChangeAuthorization(_😃 method after the location manager finishes initializing itself. Core Location calls the methods of your delegate object using the RunLoop of the thread on which you initialized the CLLocationManager object. That thread must itself have an active RunLoop, like the one found in your app’s main thread.


Determining the availability of services 确定服务的可用性

// significant-change location service 上报明显的位置更新
class func significantLocationChangeMonitoringAvailable() -> Bool// 航向数据可能无法在所有基于 iOS 的设备上使用。在要求位置管理器传递航向相关事件之前,您应该检查此方法返回的值。
class func headingAvailable() -> Bool// 一个布尔值,指示小部件(widget)是否有资格接收位置更新。
var isAuthorizedForWidgetUpdates: Bool { get }//  the level of location accuracy the app has permission to use (App有权使用的定位精度级别)
var accuracyAuthorization: CLAccuracyAuthorization { get }// 能否监控指定的区域(regionClass: A region monitoring class from the MapKit framework. This class must descend from the CLRegion class.)
class func isMonitoringAvailable(for regionClass: AnyClass) -> Bool// 最常用, 系统定位服务是否开启, 如下图所求
class func locationServicesEnabled() -> Bool

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2QvDdIQA-1678717852996)(./locationServicesEnabled.jpeg)]


Requesting authorization for location services 权限请求

1. 请求 whenInUse 定位权限

func requestWhenInUseAuthorization() 

您必须调用此方法或 requestAlwaysAuthorization() 才能接收与位置相关的信息。 只要当前授权状态未确定 (CLAuthorizationStatus.notDetermined),您就可以调用 requestWhenInUseAuthorization()。

Important

Your app must be in the foreground to show a location authorization prompt.

此方法异步运行 (runs asynchronously) 并提示用户授予应用程序使用位置服务的权限。 用户提示包含来自应用程序 Info.plist 文件中 NSLocationWhenInUseUsageDescription 键 (key) 对应的文本,调用此方法时需要存在该键, 否则会CRASH。 用户提示 (prompt alert window) 显示以下选项,这些选项确定您的 App 可以获取的授权。

OptionAuthorization
Allow While Using AppWhen In Use authorization that does not expire.
Allow OnceTemporary When In Use authorization that expires when the app is no longer in use.
Don’t AllowDenied; no further authorization requests are allowed.

在用户做出选择并确定 (determines) 状态后,位置管理器 (the location manager, 即使 CLLocationManager 实例) 将结果传递给委托的 locationManager(_:didChangeAuthorization:) 方法。 如果方法调用前的初始授权状态不是 CLAuthorizationStatus.notDetermined,则此方法不执行任何操作,也不会调用 locationManager(_:didChangeAuthorization:) 方法。

如果用户的选择向您的应用授予 When In Use 授权,则您的应用可以启动任何位置服务,并且有资格在使用时接收结果。 如果用户选择授予临时使用时授权,则当应用程序不再使用时授权将过期,恢复为未确定状态 (CLAuthorizationStatus.notDetermined)。

有关应用程序何时被视为 whenInUse 的信息,请参阅 Choosing the Location Services Authorization to Request。

前台启动定位服务 Vs 后台启动定位服务
  • foreground starts: 当您的应用程序在前台启动标准位置服务时,如果您的应用程序在 Xcode 项目的功能选项卡中启用了后台位置更新,它们将继续在后台运行。当您的应用移动到具有活动位置服务的后台时 (moves to the background with active location services),系统会在状态栏中显示位置服务指示器 (indicator)。
  • background starts: 当您的应用程序在后台运行时尝试启动位置更新将失败。

Note

在 iOS 16 及更高版本中,主动跟踪用户位置或最近启用核心位置的应用程序会在控制中心显示一个指示器 (在最顶部🔝)。 通过仅在必要时和用户期望时监视设备的位置,注意电池使用和用户隐私。

2. 请求 Always 权限

func requestAlwaysAuthorization()
Discussion 讨论

要调用此方法,您必须在应用的 Info.plist 文件中同时拥有 NSLocationAlwaysUsageDescription 和 NSLocationWhenInUseUsageDescription 键。 当前授权状态为以下任一状态时,您才可以调用:

  • Not Determined — CLAuthorizationStatus.notDetermined
  • When In Use — CLAuthorizationStatus.authorizedWhenInUse

当用户做出权限选择时,使用 CLLocationManager 委托上的 locationManager(_:didUpdateLocations:) 方法接收更新。

Core Location 限制对 requestAlwaysAuthorization() 的调用。 在您的应用程序调用此方法后,进一步的调用无效。

Request Always Authorization After Getting When In Use

要获得 Always 授权,您的应用必须首先请求 When In Use 权限,然后再请求 Always 授权。

如果用户在您的应用程序调用 requestWhenInUseAuthorization() 后授予 When In Use 权限,则调用 requestAlwaysAuthorization() 会立即提示用户请求 Always 权限。 如果用户使用 Allow Once 响应 requestWhenInUseAuthorization(),则 Core Location 会由于临时授权而忽略对 requestAlwaysAuthorization() 的进一步调用。

Core Location 提示用户使用来自 NSLocationAlwaysUsageDescription 的字符串授予权限。 用户提示显示以下选项,这些选项确定您的应用程序可以获得的授权:

OptionAuthorization
Keep Only While UsingCore Location leaves the authorization as When In Use. The delegate doesn’t receive any updates.
Change to Always AllowCore Location grants your app Always authorization. The delegate recieves CLAuthorizationStatus.authorizedAlways.
Request Always Authorization Directly

如果您的应用程序的当前状态为 CLAuthorizationStatus.notDetermined 并且您调用了 requestAlwaysAuthorization(),则 Core Location 在完全启用 Always 授权之前会使用两个提示。

第一个提示立即显示 NSLocationWhenInUseUsageDescription 中的字符串。 用户提示显示以下选项,这些选项确定您的应用程序收到的授权:

OptionAuthorization
Allow While Using AppCore Location grants your app a Provisional Always authorization. The delegate receives CLAuthorizationStatus.authorizedAlways.
Allow OnceCore Location grants your app a Temporary When in Use authorization. The delegate receives CLAuthorizationStatus.authorizedWhenInUse. This authorization expires when your app is no longer in use, reverting to CLAuthorizationStatus.notDetermined.
Don’t AllowCore Location marks your app with Denied authorization. The delegate receives CLAuthorizationStatus.denied.

当 Core Location 准备向需要 CLAuthorizationStatus.authorizedAlways 的应用程序传递事件时,会显示第二个提示。 如果应用程序处于 Provisional Always 状态,系统会显示第二个提示,其中包含来自 NSLocationAlwaysUsageDescription 的字符串。 当您的应用未运行时,Core Location 通常会显示第二个提示。

如果用户在临时始终状态下出现第二个提示时选择授予权限,您的应用程序将获得永久始终授权。 当用户响应时,您的应用会收到位置事件或使用修改后的授权调用您的委托。

当显示第二个提示时,用户会看到以下选项之一:

OptionAuthorization
Keep Only While UsingCore Location changes the authorization to When In Use. The delegate receives CLAuthorizationStatus.authorizedWhenInUse.
Change to Always AllowCore Location removes the provisional status, making the Always authorization permanent. The delegate doesn’t receive a callback.

如果用户在接近交付时间 (the time it was delivered) 响应提示并选择允许 Always 权限,则位置事件将发送到您的应用程序。

http://www.tj-hxxt.cn/news/71945.html

相关文章:

  • 企业网站建设案例哪个品牌好周口seo
  • 苏州企业网站建站系统广州百度网站快速排名
  • 山东网站建设哪家好最近军事新闻热点大事件
  • 专业建设的意义seoer是什么意思
  • 广州牌手表网站app推广赚佣金
  • 怎样免费做书画网站品牌宣传有哪些途径
  • 如何做好政府网站建设网站seo排名
  • 组建网站 多少钱搜索热度查询
  • 公司的网站链接找谁做app香港账号
  • 附近有没有学电脑的培训机构信息流优化师职业规划
  • 百度网站大全快速排名程序
  • wordpress 托管建站百度关键词排名查询接口
  • 企业网站管理系统设置seo整站优化外包公司
  • wordpress动画二十条优化措施
  • 专业网站建设 公司哪家好广州网站推广联盟
  • 图片编辑软件seocui cn
  • 网站数据分析表格达州seo
  • 做政府网站运营热点军事新闻
  • 当当网网站内容建设的分析网络营销外包网络推广
  • 中旅远洋商务网站建设策划书微信推广软件有哪些
  • 在香港做网站的步骤网站设计制作的服务怎么样
  • 网站建设中的多语言翻译如何实现线上it培训机构
  • 英德建设网站搜索引擎优化网页
  • 做会员卡的网站在线制作南京百度搜索优化
  • 怎么看别人网站是哪里做的友情链接交换平台免费
  • 商务网站建设工程师seo整站网站推广优化排名
  • 党委门户网站建设意义2022年五月份热点事件
  • 门户网站建设情况总结网络推广公司方案
  • 茶叶网站建设网页设计制作社群营销策略有哪些
  • 商城和营销型网站建设seo快速上排名