You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "dpogue (via GitHub)" <gi...@apache.org> on 2026/08/26 01:24:53 UTC
[PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
dpogue opened a new pull request, #1698:
URL: https://github.com/apache/cordova-ios/pull/1698
I expect this to be potentially controversial given the state of APIs here, but I believe it is safe and will remove the need for the geolocation plugin for apps targeting iOS 15 and newer.
It would be nice if there were a way to test that this passes Apple's automatic API usage scan before merging 😕
### Platforms affected
iOS (15+)
### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->
This method allows controlling whether access to the geolocation API is available based on the origin requesting access. This resolves the primary reason that the Cordova Geolocation plugin exists.
### Description
<!-- Describe your changes in detail -->
However, the API is only available as public API in iOS 27 and newer, but has been available as private API with the same signature since iOS 15. Since we're allowed to declare the public API now, we can do that and then dynamically alias it to the private API for older iOS versions.
A new `GeolocationPermissionGrantType` preference is supported in config.xml, following the same rules as the media permissions. If not specified, the app scheme will have access to geolocation APIs, but no other origins.
Any geolocation access requires the `NSLocationWhenInUseUsageDescription` option to be set in Info.plist, otherwise the app will crash when initializing Location Services.
### Testing
<!-- Please describe in detail how you tested your changes. -->
Confirmed that this allows geolocation to work with just a single prompt in a Cordova app, without the need for the geolocation plugin.
### Checklist
- [ ] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [ ] I've updated the documentation if necessary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5832523319
> All we're doing is declaring a method on a class, and conditionally declaring that same method with a slightly different name on older versions. This should be perfectly safe.
Perhaps I misunderstood something, but my feedback was primarily being driven by the fact that [webView:requestGeolocationPermissionForOrigin:initiatedByFrame:decisionHandler:](https://developer.apple.com/documentation/webkit/wkuidelegate/webview(_:requestgeolocationpermissionfor:initiatedbyframe:decisionhandler:)?language=objc) is an iOS 27+ API and we are accessing it dynamically inside `@available(iOS 15.0, *)` block.
And based on the comments in the code:
```
// The same API exists as private API (prefixed with an underscore) as far
// back as iOS 15, but we're not allowed to implement it directly. Since
// it's solifidied now into public API, we can be assured that the private
// API signature won't change in future iOS versions, so we can grab the
// implementation of the public API and dynamically inject it with the
// private API method signature.
...
/* Alias the public API delegate method to the private API */
```
paired with the usage of the private selector, it looked to me that we are accessing a private API.
Just wanted to apologize if I was completely off base here, but I'll leave it at that since the PR is closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5419310717
## [Codecov](https://app.codecov.io/gh/apache/cordova-ios/pull/1698?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 80.02%. Comparing base ([`f525ec9`](https://app.codecov.io/gh/apache/cordova-ios/commit/f525ec9ec8b434f79928c66dff2bca06e178066d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2fcedd2`](https://app.codecov.io/gh/apache/cordova-ios/commit/2fcedd29798d3fae11e326d22eb69c849c4a6363?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #1698 +/- ##
==========================================
- Coverage 81.76% 80.02% -1.75%
==========================================
Files 17 17
Lines 5161 5161
==========================================
- Hits 4220 4130 -90
- Misses 941 1031 +90
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cordova-ios/pull/1698?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5831839572
I don't understand why you react in this way. That was just a review made with AI. I even marked my comments as general feedback not as something which must be changed. If you are against AI, than you shouldn't use the internet, computers and mobile phones any more. AI is already built-in everywhere and more and more content will be generated with it. AI makes failures and have to learn, this is always declared everywhere when you use AI. AI can be a helper but for sure should not turn off your brain when using generated content for it. Rather than reacting in this way you could have just reply why the AI generated review is maybe assuming something wrong or why this wouldn't affect an App review. You also even noted in your PR description that `It would be nice if there were a way to test that this passes Apple's automatic API usage scan before merging 😕`. So if I understand correct you are not sure if this would pass an App Review. Nobody is perfect, not me, not AI, not anyb
ody else.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5815099045
Anything that breaches the apple guidelines I think is a valid concern. Apple is really stingy in their app reviews, and even if this was used today and passed app reviews, it doesn't mean they won't randomly reject an app later on citing Section 2.5.1.
I've had rejections From Apple because of particular components that the App had that had existed in the app for years before they decided to take issue with it. Point here being that Apple reviews are not always consistent and is subjected to the reviewer's discretion. We can get reports from 100 different people stating they successfully submitted an app with this update and the 101th submission apple could reject due to this change. So I'd be worried that using a private API could cause problems later.
I understand that the API itself became public in the iOS 27 SDK, so this is kind of a gray area -- but technically speaking the API isn't public on iOS 15-26, so it should be considered unsafe to use directly on those versions and we are hacking our way around that so that we can use it directly.
All of this is kind of theoretical, but should this become a real issue -- reverting this kind of update after people rely on it might cause an even bigger headache. And once it's flagged for one app submission, the only option that user would have to get their app approved is to downgrade to a cordova-ios framework to a version that doesn't include this change, which might not be practically possible.
Taking 2.5.1 as literal as possible, you'd have to assume it won't consistently pass app review, because it states that Apps may only use public APIs, and the consequences of a rejection would have severe implications; so unfortunately, I think this is something that we shouldn't accept as is. We either need a graceful fallback for devices older than iOS 27, a fallback that doesn't involve accessing a private API on those device versions, or we must wait until we can set our deployment target to iOS 27, which obviously would not be anytime soon.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5801409830
I'm really not interested in what AI thinks of the code, when I've already explained in detail why we're falling back to implementing a private API and why that should be safe in this case, and the implementation matches the behaviour of the camera/microphone media access policy preference. If someone has actual objections to that, please say what those objections are instead of just saying something that's already known information.
If people can't be bothered to use their brains to look at code and read what's been written, then I'm not particularly interested in contributing code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5801840308
Hey @dpogue,
using AI for reviewing was just a helper to make a review and push things forward. It was not meant to bother you. AI is a tool like we use search engines which for e.g. points us to StackOverflow. I just wanted to make a fast review.
I was just concerned about, that it mentioned something about
> This exposes consuming apps to rejection under [Apple’s guideline 2.5.1](https://developer.apple.com/app-store/review/guidelines/#software-requirements)
when it was about the private API fallback. When this is wrong than everything is good to go? But anyway, should this feature be documented somewhere in cordova-docs? Which place but be best for it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5437808142
Is this read to review?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5815188464
> All of this is kind of theoretical
There is older precedent based on: https://ajnaware.wordpress.com/2009/09/24/yet-another-dubious-app-rejection-story/
And while the blog author denies actually using any private APIs, their posted Apple response states that their app was using APIs marked as private on iOS 3.0 and those APIs were only available as public APIs on iOS 3.1.
The author went on to say that Apple basically requested the author to change the min deployment to 3.1+ if they wanted to use APIs introduced publicly in 3.1.
> However, the bad news was that Apple was requesting me to resubmit the app for deployment only on OS3.1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5828108900
So if you read the PR, you'll see that we're not calling any private APIs anywhere (unlike projects like [Capacitor](https://github.com/ionic-team/capacitor/blob/145560ee590d86637dc9dd2e2c9f4c08b0f631c0/ios/Capacitor/Capacitor/WKWebView%2BCapacitor.swift#L33-L70) which unconditionally call private APIs as part of their core functionality, and have been doing so for years).
All we're doing is declaring a method on a class, and conditionally declaring that same method with a slightly different name on older versions. This should be perfectly safe.
That said, the more this project gets overrun with AI slop, the less I care to be involved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#issuecomment-5445254653
This is ready for review, but should not be merged until after iOS 27 is released
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on code in PR #1698:
URL: https://github.com/apache/cordova-ios/pull/1698#discussion_r4083532143
##########
CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewUIDelegate.m:
##########
@@ -31,6 +35,42 @@ @implementation CDVWebViewUIDelegate
NSMutableArray<UIViewController *> *windows;
}
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 270000
++ (void)load {
+ // iOS 27 makes public a delegate method for determining whether
+ // geolocation should be allowed for a given origin:
+ //
+ // - webView:requestGeolocationPermissionForOrigin:initiatedByFrame:decisionHandler:
+ //
+ // This removes one of the main reasons for apps to need the geolocation
+ // plugin.
+ //
+ // The same API exists as private API (prefixed with an underscore) as far
+ // back as iOS 15, but we're not allowed to implement it directly. Since
+ // it's solifidied now into public API, we can be assured that the private
+ // API signature won't change in future iOS versions, so we can grab the
+ // implementation of the public API and dynamically inject it with the
+ // private API method signature.
+ //
+ // Is this best practice? No.
+ // Is this safe? Probably.
+ // Is this useful for apps that use geolocation? Definitely.
+ if (@available(iOS 27.0, *)) {
+ /* Do nothing - iOS 27 supports the public API delegate method */
+ } else if (@available(iOS 15.0, *)) {
+ /* Alias the public API delegate method to the private API */
+ Class class = [self class];
+
+ SEL publicSelector = @selector(webView:requestGeolocationPermissionForOrigin:initiatedByFrame:decisionHandler:);
+ SEL privateSelector = NSSelectorFromString([NSString stringWithFormat:@"_%@", NSStringFromSelector(publicSelector)]);
+
+ Method publicMethod = class_getInstanceMethod(class, publicSelector);
+
+ class_addMethod(class, privateSelector, method_getImplementation(publicMethod), method_getTypeEncoding(publicMethod));
Review Comment:
AI noted here:
> High priority: remove the private API fallback. [CDVWebViewUIDelegate.m, lines 60–69](https://github.com/apache/cordova-ios/blob/2fcedd29798d3fae11e326d22eb69c849c4a6363/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewUIDelegate.m#L60) dynamically registers the private selector on iOS 15–26. Constructing its name at runtime does not make it public API, and publishing an equivalent in iOS 27 does not retroactively authorize the older API. This exposes consuming apps to rejection under [Apple’s guideline 2.5.1](https://developer.apple.com/app-store/review/guidelines/#software-requirements). Passing an automated scan would not resolve that concern. Keep the public iOS 27 implementation and retain the plugin approach for older versions.
##########
CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m:
##########
@@ -278,6 +278,7 @@ - (void)pluginInitialize
uiDelegate.title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
uiDelegate.mediaPermissionGrantType = [self parsePermissionGrantType:[settings cordovaSettingForKey:@"MediaPermissionGrantType"]];
+ uiDelegate.geolocationPermissionGrantType = [self parsePermissionGrantType:[settings cordovaSettingForKey:@"GeolocationPermissionGrantType"]];
Review Comment:
AI noted here:
> Medium priority: reconcile the default permission behavior with the stated intent.
>
> The new preference assignment uses a parser that defaults to `grantIfSameHostElsePrompt`. Consequently, other hosts can obtain permission through a prompt, whereas the PR description says only the app scheme gets access by default. The comparison also checks only the hostname, ignoring scheme and port. Either implement the intended restriction or explicitly document the broader policy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] feat(geolocation): Implement WKUIDelegate geolocation permission method [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue closed pull request #1698: feat(geolocation): Implement WKUIDelegate geolocation permission method
URL: https://github.com/apache/cordova-ios/pull/1698
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org