Skip to content

fix(ios): remove usage of APIs deprecated in iOS 14 and iOS 15 - #163

Merged
andredestro merged 1 commit into
mainfrom
RMET-5363
Aug 26, 2026
Merged

fix(ios): remove usage of APIs deprecated in iOS 14 and iOS 15#163
andredestro merged 1 commit into
mainfrom
RMET-5363

Conversation

@andredestro

Copy link
Copy Markdown
Contributor

Fixes the iOS 14 and iOS 15 deprecation warnings in the geolocation and notifications code (RMET-5363). A clean xcodebuild of the plugin emitted four of them:

Geolocation.swift:39:30: warning: 'authorizationStatus()' was deprecated in iOS 14.0
Geolocation.swift:58:34: warning: 'authorizationStatus()' was deprecated in iOS 14.0
Geolocation.swift:77:30: warning: 'authorizationStatus()' was deprecated in iOS 14.0
Notifications.swift:155:33: warning: 'summaryArgument' was deprecated in iOS 15.0: summaryArgument is ignored

Geolocation

CLLocationManager.authorizationStatus() is deprecated in iOS 14 in favour of the authorizationStatus instance property (API_DEPRECATED_WITH_REPLACEMENT("-authorizationStatus", ios(4.2, 14.0))), so this is a direct replacement with no behaviour change.

  • init and requestPermission() read the status from the instance's own locationManager.
  • checkPermission() stays static, so it reads from a type-level CLLocationManager. This keeps the callers unchanged and avoids allocating a manager on every permission check (it runs on every getCurrentPosition() / startWatchingPosition() call coming from JS).
  • Dropped the .authorized case from the switch: it is the legacy alias of .authorizedAlways with the same raw value, and default already covers unknown values.

Notifications

summaryArgument on UNMutableNotificationContent is deprecated since iOS 15 and the value is ignored by the system, so it is no longer set on the notification content.

The summaryArgument schedule option is not removed from the public API. It is marked as @deprecated with a note that it has no effect, so no app breaks at build time over an option the OS discards anyway. Docs were regenerated with docgen.

groupSummary is also dropped from the iOS NotificationOption: it was parsed and never used. The option keeps working on Android, which has its own model.

Out of scope

The build still reports one non-deprecation warning, capture of 'self' with non-Sendable type 'CapacitorGeolocation' in a '@Sendable' closure (Geolocation.swift:88), left untouched on purpose. It becomes an error under the Swift 6 language mode and deserves its own change.

Verification

  • xcodebuild -scheme CapacitorBackgroundRunner -destination 'generic/platform=iOS': BUILD SUCCEEDED, no deprecat match anywhere in the full log.
  • xcodebuild test on an iPhone 17 Pro simulator: TEST SUCCEEDED, 15 tests, 0 failures.
  • swiftlint with the repo config: compared before and after, no new violations (only line-number shifts of pre-existing ones in Geolocation.swift).
  • tsc --noEmit, prettier --check and eslint clean (the 3 eslint warnings in web.ts are pre-existing).

Geolocation: replace the `CLLocationManager.authorizationStatus()` class
method, deprecated in iOS 14, with the `authorizationStatus` instance
property. `checkPermission()` stays static and reads the status from a
type-level `CLLocationManager`, so callers are unchanged and no manager is
allocated per permission check. The `.authorized` case is dropped as well,
since it is the legacy alias of `.authorizedAlways` and matches the same
raw value.

Notifications: stop setting `summaryArgument` on
`UNMutableNotificationContent`. It is deprecated since iOS 15 and the
system ignores the value. The `summaryArgument` schedule option is kept
and marked as deprecated instead of removed, so the public API does not
break. `groupSummary` is also dropped from the iOS `NotificationOption`,
where it was parsed but never used; Android keeps its own model and is
unaffected.
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b73444

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@capacitor/background-runner Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@andredestro
andredestro merged commit 8981234 into main Aug 26, 2026
15 of 18 checks passed
@andredestro
andredestro deleted the RMET-5363 branch August 26, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants