Skip to content

Commit

Permalink
Merge pull request #124 from ooni/warn-vpn-ios
Browse files Browse the repository at this point in the history
feat: add iOS Open VPN Settings
  • Loading branch information
sdsantos authored Sep 20, 2024
2 parents 59ab4cd + 6372258 commit 93ed2ce
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SetupDependencies(
launchUrl = ::launchUrl,
startSingleRunInner = ::startSingleRun,
configureAutoRun = ::configureAutoRun,
openVpnSettings = { false },
openVpnSettings = ::openVpnSettings,
)

fun startSingleRun(spec: RunSpecification) {
Expand Down Expand Up @@ -235,4 +235,17 @@ class SetupDependencies(
operation.completionBlock = { task.setTaskCompletedWithSuccess(!operation.isCancelled()) }
operationQueue.addOperation(operation)
}

private fun openVpnSettings(): Boolean {
val url = "App-prefs:General&path=ManagedConfigurationList"
return NSURL.URLWithString(url)?.let {
if (UIApplication.sharedApplication.canOpenURL(it)) {
UIApplication.sharedApplication.openURL(it)
return@let true
} else {
Logger.e { "Cannot open URL: $url" }
return@let false
}
} ?: false
}
}

0 comments on commit 93ed2ce

Please sign in to comment.