Instance Property インスタンスプロパティ

allowsConstrainedNetworkAccess

A Boolean value that indicates whether the request may use the network when the user has specified Low Data Mode. あるブール値、それはユーザがLow Data Modeを指定する場合にリクエストがネットワークを使うかもしれないかどうかを指し示します。

Declaration 宣言

var allowsConstrainedNetworkAccess: Bool { get set }

Discussion 議論

In iOS 13 and later, users can set their device to use Low Data Mode as one of the Cellular Data Options in the Settings app. Users can turn on Low Data Mode to reduce your app’s network data usage. This property controls the request’s behavior when the user turns on Low Data Mode. If there are no nonconstrained network interfaces available and the request’s allowsConstrainedNetworkAccess property is false, any connection created from the request fails. In this case, the error provided when the connection fails has a networkUnavailableReason property whose value is NSURLErrorNetworkUnavailableReason.constrained. iOS 13以降では、ユーザは彼らのデバイスを、「省データモード」を「通信のオプション」の1つとして使うように設定することが「設定」アプリにおいて可能です。ユーザは、「省データモード」を入りにして、あなたのアプリのネットワークデータ利用を減らせます。このプロパティは、ユーザが「省データモード」を入りにする時に、リクエストの挙動を制御します。利用可能な非制約ネットワークインターフェイスがない、そしてリクエストのもつallowsConstrainedNetworkAccessプロパティがfalseならば、リクエストから作成されたどんな接続も失敗します。この場合、接続が失敗する場合に提供されたエラーは、networkUnavailableReasonプロパティをもち、それの値はNSURLErrorNetworkUnavailableReason.constrainedです。

Setting this property on a request overrides the allowsConstrainedNetworkAccess property of URLSessionConfiguration. For example, if the session configuration’s allowsConstrainedNetworkAccess value is false, and you create a task from a request whose allowsConstrainedNetworkAccess is true, the task treats the value as true. このプロパティをあるリクエスト上で設定することは、URLSessionConfigurationallowsConstrainedNetworkAccessプロパティをオーバーライドします。例えば、セッション構成設定のもつallowsConstrainedNetworkAccess値がfalseである、そしてあなたがあるタスクをそれのallowsConstrainedNetworkAccesstrueであるリクエストから作成するならば、タスクはその値をtrueであるとみなします。

Limit your app’s of use of constrained network access to user-initiated tasks, and put off discretionary tasks until a nonconstrained interface becomes available. あなたのアプリのもつ制約付ネットワークアクセス利用を、ユーザ開始タスクに制限してください、そして自由裁量タスクを延期してください、非制約インターフェイスが利用可能になるまで。

See Also 参照

Supporting Limited Modes 制限モードをサポートする