mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-30 21:59:36 +02:00
chore(ios): consolidate optional argument standard (#1738)
* chore(ios): consolidate optional argument standard mark all optional iOS arguments as `var <name>: Type?`, following the pattern described in the documentation: https://v2.tauri.app/develop/plugins/develop-mobile/#ios * chore: add missing Info.plist to example
This commit is contained in:
1 parent
713c54ef83
commit
a34fade500
9 files changed
+68
-60
No files matched your search
@@ -1,10 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSCameraUsageDescription</key>
|
<key>NSCameraUsageDescription</key>
|
||||||
<string>Request camera access for WebRTC</string>
|
<string>Request camera access for WebRTC</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>Request microphone access for WebRTC</string>
|
<string>Request microphone access for WebRTC</string>
|
||||||
</dict>
|
<key>NSFaceIDUsageDescription</key>
|
||||||
|
<string>Authenticate with biometrics</string>
|
||||||
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>NSFaceIDUsageDescription</key>
|
||||||
|
<string>Authenticate with biometrics</string>
|
||||||
<key>NSCameraUsageDescription</key>
|
<key>NSCameraUsageDescription</key>
|
||||||
<string>Request camera access for WebRTC</string>
|
<string>Request camera access for WebRTC</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import WebKit
|
|||||||
|
|
||||||
struct ScanOptions: Decodable {
|
struct ScanOptions: Decodable {
|
||||||
var formats: [SupportedFormat]?
|
var formats: [SupportedFormat]?
|
||||||
let windowed: Bool?
|
var windowed: Bool?
|
||||||
let cameraDirection: String?
|
var cameraDirection: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SupportedFormat: String, CaseIterable, Decodable {
|
enum SupportedFormat: String, CaseIterable, Decodable {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class BiometricStatus {
|
|||||||
struct AuthOptions: Decodable {
|
struct AuthOptions: Decodable {
|
||||||
let reason: String
|
let reason: String
|
||||||
var allowDeviceCredential: Bool?
|
var allowDeviceCredential: Bool?
|
||||||
let fallbackTitle: String?
|
var fallbackTitle: String?
|
||||||
let cancelTitle: String?
|
var cancelTitle: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
class BiometricPlugin: Plugin {
|
class BiometricPlugin: Plugin {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import CoreLocation
|
||||||
import SwiftRs
|
import SwiftRs
|
||||||
import Tauri
|
import Tauri
|
||||||
import UIKit
|
import UIKit
|
||||||
import WebKit
|
import WebKit
|
||||||
import CoreLocation
|
|
||||||
|
|
||||||
class GetPositionArgs: Decodable {
|
class GetPositionArgs: Decodable {
|
||||||
let enableHighAccuracy: Bool?
|
var enableHighAccuracy: Bool?
|
||||||
}
|
}
|
||||||
|
|
||||||
class WatchPositionArgs: Decodable {
|
class WatchPositionArgs: Decodable {
|
||||||
@@ -101,14 +101,14 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
|
|||||||
if CLLocationManager.locationServicesEnabled() {
|
if CLLocationManager.locationServicesEnabled() {
|
||||||
// TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead.
|
// TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead.
|
||||||
switch CLLocationManager.authorizationStatus() {
|
switch CLLocationManager.authorizationStatus() {
|
||||||
case .notDetermined:
|
case .notDetermined:
|
||||||
status = "prompt"
|
status = "prompt"
|
||||||
case .restricted, .denied:
|
case .restricted, .denied:
|
||||||
status = "denied"
|
status = "denied"
|
||||||
case .authorizedAlways, .authorizedWhenInUse:
|
case .authorizedAlways, .authorizedWhenInUse:
|
||||||
status = "granted"
|
status = "granted"
|
||||||
@unknown default:
|
@unknown default:
|
||||||
status = "prompt"
|
status = "prompt"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
invoke.reject("Location services are not enabled.")
|
invoke.reject("Location services are not enabled.")
|
||||||
@@ -161,16 +161,18 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
public func locationManager(
|
||||||
|
_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]
|
||||||
|
) {
|
||||||
// Respond to all getCurrentPosition() calls.
|
// Respond to all getCurrentPosition() calls.
|
||||||
for request in self.positionRequests {
|
for request in self.positionRequests {
|
||||||
// The capacitor plugin uses locations.first but .last should be the most current one
|
// The capacitor plugin uses locations.first but .last should be the most current one
|
||||||
// and i don't see a reason to use old locations
|
// and i don't see a reason to use old locations
|
||||||
if let location = locations.last {
|
if let location = locations.last {
|
||||||
let result = convertLocation(location)
|
let result = convertLocation(location)
|
||||||
request.resolve(result)
|
request.resolve(result)
|
||||||
} else {
|
} else {
|
||||||
request.reject("Location service returned an empty Location array.")
|
request.reject("Location service returned an empty Location array.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +196,9 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
|
public func locationManager(
|
||||||
|
_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus
|
||||||
|
) {
|
||||||
let requests = self.permissionRequests
|
let requests = self.permissionRequests
|
||||||
self.permissionRequests.removeAll()
|
self.permissionRequests.removeAll()
|
||||||
|
|
||||||
|
|||||||
@@ -16,24 +16,24 @@ enum ScanKind: Decodable {
|
|||||||
|
|
||||||
struct ScanOptions: Decodable {
|
struct ScanOptions: Decodable {
|
||||||
let kind: ScanKind
|
let kind: ScanKind
|
||||||
let keepSessionAlive: Bool?
|
var keepSessionAlive: Bool?
|
||||||
let message: String?
|
var message: String?
|
||||||
let successMessage: String?
|
var successMessage: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NDEFRecord: Decodable {
|
struct NDEFRecord: Decodable {
|
||||||
let format: UInt8?
|
var format: UInt8?
|
||||||
let kind: [UInt8]?
|
var kind: [UInt8]?
|
||||||
let identifier: [UInt8]?
|
var identifier: [UInt8]?
|
||||||
let payload: [UInt8]?
|
var payload: [UInt8]?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WriteOptions: Decodable {
|
struct WriteOptions: Decodable {
|
||||||
let kind: ScanKind?
|
var kind: ScanKind?
|
||||||
let records: [NDEFRecord]
|
let records: [NDEFRecord]
|
||||||
let message: String?
|
var message: String?
|
||||||
let successMessage: String?
|
var successMessage: String?
|
||||||
let successfulReadMessage: String?
|
var successfulReadMessage: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TagProcessMode {
|
enum TagProcessMode {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class NotificationHandler: NSObject, NotificationHandlerProtocol {
|
|||||||
try? self.plugin?.trigger("notification", data: notificationData)
|
try? self.plugin?.trigger("notification", data: notificationData)
|
||||||
|
|
||||||
if let options = notificationsMap[notification.request.identifier] {
|
if let options = notificationsMap[notification.request.identifier] {
|
||||||
if options.silent {
|
if options.silent ?? false {
|
||||||
return UNNotificationPresentationOptions.init(rawValue: 0)
|
return UNNotificationPresentationOptions.init(rawValue: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ enum ScheduleEveryKind: String, Decodable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ScheduleInterval: Decodable {
|
struct ScheduleInterval: Decodable {
|
||||||
let year: Int?
|
var year: Int?
|
||||||
let month: Int?
|
var month: Int?
|
||||||
let day: Int?
|
var day: Int?
|
||||||
let weekday: Int?
|
var weekday: Int?
|
||||||
let hour: Int?
|
var hour: Int?
|
||||||
let minute: Int?
|
var minute: Int?
|
||||||
let second: Int?
|
var second: Int?
|
||||||
}
|
}
|
||||||
|
|
||||||
enum NotificationSchedule: Decodable {
|
enum NotificationSchedule: Decodable {
|
||||||
@@ -67,13 +67,13 @@ struct Notification: Decodable {
|
|||||||
var title: String
|
var title: String
|
||||||
var body: String?
|
var body: String?
|
||||||
var extra: [String: String]?
|
var extra: [String: String]?
|
||||||
let schedule: NotificationSchedule?
|
var schedule: NotificationSchedule?
|
||||||
let attachments: [NotificationAttachment]?
|
var attachments: [NotificationAttachment]?
|
||||||
let sound: String?
|
var sound: String?
|
||||||
let group: String?
|
var group: String?
|
||||||
let actionTypeId: String?
|
var actionTypeId: String?
|
||||||
let summary: String?
|
var summary: String?
|
||||||
var silent = false
|
var silent: Bool?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RemoveActiveNotification: Decodable {
|
struct RemoveActiveNotification: Decodable {
|
||||||
@@ -130,19 +130,19 @@ struct Action: Decodable {
|
|||||||
var foreground: Bool?
|
var foreground: Bool?
|
||||||
var destructive: Bool?
|
var destructive: Bool?
|
||||||
var input: Bool?
|
var input: Bool?
|
||||||
let inputButtonTitle: String?
|
var inputButtonTitle: String?
|
||||||
let inputPlaceholder: String?
|
var inputPlaceholder: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ActionType: Decodable {
|
struct ActionType: Decodable {
|
||||||
let id: String
|
let id: String
|
||||||
let actions: [Action]
|
let actions: [Action]
|
||||||
let hiddenPreviewsBodyPlaceholder: String?
|
var hiddenPreviewsBodyPlaceholder: String?
|
||||||
var customDismissAction: Bool?
|
var customDismissAction: Bool?
|
||||||
var allowInCarPlay: Bool?
|
var allowInCarPlay: Bool?
|
||||||
var hiddenPreviewsShowTitle: Bool?
|
var hiddenPreviewsShowTitle: Bool?
|
||||||
var hiddenPreviewsShowSubtitle: Bool?
|
var hiddenPreviewsShowSubtitle: Bool?
|
||||||
let hiddenBodyPlaceholder: String?
|
var hiddenBodyPlaceholder: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RegisterActionTypesArgs: Decodable {
|
struct RegisterActionTypesArgs: Decodable {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import UIKit
|
|||||||
import WebKit
|
import WebKit
|
||||||
|
|
||||||
class PingArgs: Decodable {
|
class PingArgs: Decodable {
|
||||||
let value: String?
|
var value: String?
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExamplePlugin: Plugin {
|
class ExamplePlugin: Plugin {
|
||||||
|
|||||||
Reference in new issue
Block a user