Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lucky-otters-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@capacitor/background-runner": minor
---

(iOS): Fixes the iOS 14 and iOS 15 deprecation warnings in the geolocation and notifications APIs. The deprecated `CLLocationManager.authorizationStatus()` class method is replaced by the `authorizationStatus` instance property, and `summaryArgument` is no longer set on scheduled notifications because iOS ignores it since iOS 15. The `summaryArgument` notification option is deprecated and now has no effect.
2 changes: 1 addition & 1 deletion packages/capacitor-plugin/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Send basic local notifications.
| **`sound`** | <code>string</code> | Name of the audio file to play when this notification is displayed. Include the file extension with the filename. On iOS, the file should be in the app bundle. On Android, the file should be in res/raw folder. Recommended format is `.wav` because is supported by both iOS and Android. Only available for iOS and Android &lt; 26. For Android 26+ use channelId of a channel configured with the desired sound. If the sound file is not found, (i.e. empty string or wrong name) the default system notification sound will be used. If not provided, it will produce the default sound on Android and no sound on iOS. | 1.0.0 |
| **`actionTypeId`** | <code>string</code> | Associate an action type with this notification. | 1.0.0 |
| **`threadIdentifier`** | <code>string</code> | Used to group multiple notifications. Sets `threadIdentifier` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Sets `summaryArgument` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Only available for iOS. **This option has no effect.** `summaryArgument` on [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent) is deprecated since iOS 15 and the value is ignored by the system, so it is no longer set on the notification content. | 1.0.0 |
| **`group`** | <code>string</code> | Used to group multiple notifications. Calls `setGroup()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android. | 1.0.0 |
| **`groupSummary`** | <code>string</code> | If true, this notification becomes the summary for a group of notifications. Calls `setGroupSummary()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android when using `group`. | 1.0.0 |
| **`extra`** | <code>any</code> | Set extra data to store within this notification. | 1.0.0 |
Expand Down
2 changes: 1 addition & 1 deletion packages/capacitor-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ Send basic local notifications.
| **`sound`** | <code>string</code> | Name of the audio file to play when this notification is displayed. Include the file extension with the filename. On iOS, the file should be in the app bundle. On Android, the file should be in res/raw folder. Recommended format is `.wav` because is supported by both iOS and Android. Only available for iOS and Android &lt; 26. For Android 26+ use channelId of a channel configured with the desired sound. If the sound file is not found, (i.e. empty string or wrong name) the default system notification sound will be used. If not provided, it will produce the default sound on Android and no sound on iOS. | 1.0.0 |
| **`actionTypeId`** | <code>string</code> | Associate an action type with this notification. | 1.0.0 |
| **`threadIdentifier`** | <code>string</code> | Used to group multiple notifications. Sets `threadIdentifier` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Sets `summaryArgument` on the [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent). Only available for iOS. | 1.0.0 |
| **`summaryArgument`** | <code>string</code> | The string this notification adds to the category's summary format string. Only available for iOS. **This option has no effect.** `summaryArgument` on [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent) is deprecated since iOS 15 and the value is ignored by the system, so it is no longer set on the notification content. | 1.0.0 |
| **`group`** | <code>string</code> | Used to group multiple notifications. Calls `setGroup()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android. | 1.0.0 |
| **`groupSummary`** | <code>string</code> | If true, this notification becomes the summary for a group of notifications. Calls `setGroupSummary()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android when using `group`. | 1.0.0 |
| **`extra`** | <code>any</code> | Set extra data to store within this notification. | 1.0.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ enum CapacitorGeolocationErrors: Error, Equatable {
}

class CapacitorGeolocation: NSObject, CapacitorGeolocationExports, CLLocationManagerDelegate {
private static let permissionManager = CLLocationManager()

private weak var context: Context?
private var pendingCurrentLocationCalls: [Int: (Result<CLLocation?, Error>) -> Void] = [:]
private var isWatchingLocation: Bool = false
Expand All @@ -36,7 +38,7 @@ class CapacitorGeolocation: NSObject, CapacitorGeolocationExports, CLLocationMan
self.context = context
self.locationManager.delegate = self

if CLLocationManager.authorizationStatus() == .authorizedAlways {
if self.locationManager.authorizationStatus == .authorizedAlways {
self.locationManager.allowsBackgroundLocationUpdates = true
self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
self.locationManager.pausesLocationUpdatesAutomatically = false
Expand All @@ -55,8 +57,8 @@ class CapacitorGeolocation: NSObject, CapacitorGeolocationExports, CLLocationMan

var permission: String = "prompt"

switch CLLocationManager.authorizationStatus() {
case .authorized, .authorizedWhenInUse, .authorizedAlways:
switch permissionManager.authorizationStatus {
case .authorizedWhenInUse, .authorizedAlways:
permission = "granted"
case .notDetermined:
permission = "prompt"
Expand All @@ -74,7 +76,7 @@ class CapacitorGeolocation: NSObject, CapacitorGeolocationExports, CLLocationMan
return
}

if CLLocationManager.authorizationStatus() != .notDetermined {
if self.locationManager.authorizationStatus != .notDetermined {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ struct NotificationOption {
let actionTypeId: String?
let extra: [String: Any]?
let threadIdentifier: String?
let summaryArgument: String?
let groupSummary: String?

init(from dict: [String: Any?]) throws {
guard let id = dict["id"] as? Int else {
Expand All @@ -58,8 +56,6 @@ struct NotificationOption {
self.sound = dict["sound"] as? String
self.actionTypeId = dict["actionTypeId"] as? String
self.extra = dict["extra"] as? [String: Any]
self.summaryArgument = dict["summaryArgument"] as? String
self.groupSummary = dict["groupSummary"] as? String
}
}

Expand Down Expand Up @@ -151,10 +147,6 @@ class CapacitorNotifications: NSObject, CapacitorNotificationsExports {
content.threadIdentifier = threadIdentifier
}

if let summaryArgument = notificationOption.summaryArgument {
content.summaryArgument = summaryArgument
}

if let sound = notificationOption.sound {
content.sound = UNNotificationSound(named: UNNotificationSoundName(sound))
}
Expand Down
9 changes: 6 additions & 3 deletions packages/capacitor-plugin/src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ export interface NotificationScheduleOptions {
/**
* The string this notification adds to the category's summary format string.
*
* Sets `summaryArgument` on the
* [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent).
*
* Only available for iOS.
*
* **This option has no effect.** `summaryArgument` on
* [`UNMutableNotificationContent`](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent)
* is deprecated since iOS 15 and the value is ignored by the system, so it is
* no longer set on the notification content.
*
* @since 1.0.0
* @deprecated This option has no effect, iOS ignores it since iOS 15.
*/
summaryArgument?: string;
/**
Expand Down
Loading