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
pull/1758/head
Lucas Fernandes Nogueira 9 months ago committed by GitHub
parent 713c54ef83
commit a34fade500
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,10 +1,12 @@
<?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">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Request camera access for WebRTC</string>
<key>NSMicrophoneUsageDescription</key>
<string>Request microphone access for WebRTC</string>
</dict>
<dict>
<key>NSCameraUsageDescription</key>
<string>Request camera access for WebRTC</string>
<key>NSMicrophoneUsageDescription</key>
<string>Request microphone access for WebRTC</string>
<key>NSFaceIDUsageDescription</key>
<string>Authenticate with biometrics</string>
</dict>
</plist>

@ -40,6 +40,8 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSFaceIDUsageDescription</key>
<string>Authenticate with biometrics</string>
<key>NSCameraUsageDescription</key>
<string>Request camera access for WebRTC</string>
<key>NSMicrophoneUsageDescription</key>

@ -9,8 +9,8 @@ import WebKit
struct ScanOptions: Decodable {
var formats: [SupportedFormat]?
let windowed: Bool?
let cameraDirection: String?
var windowed: Bool?
var cameraDirection: String?
}
enum SupportedFormat: String, CaseIterable, Decodable {

@ -25,8 +25,8 @@ class BiometricStatus {
struct AuthOptions: Decodable {
let reason: String
var allowDeviceCredential: Bool?
let fallbackTitle: String?
let cancelTitle: String?
var fallbackTitle: String?
var cancelTitle: String?
}
class BiometricPlugin: Plugin {

@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import CoreLocation
import SwiftRs
import Tauri
import UIKit
import WebKit
import CoreLocation
class GetPositionArgs: Decodable {
let enableHighAccuracy: Bool?
var enableHighAccuracy: Bool?
}
class WatchPositionArgs: Decodable {
@ -101,14 +101,14 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
if CLLocationManager.locationServicesEnabled() {
// TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead.
switch CLLocationManager.authorizationStatus() {
case .notDetermined:
status = "prompt"
case .restricted, .denied:
status = "denied"
case .authorizedAlways, .authorizedWhenInUse:
status = "granted"
@unknown default:
status = "prompt"
case .notDetermined:
status = "prompt"
case .restricted, .denied:
status = "denied"
case .authorizedAlways, .authorizedWhenInUse:
status = "granted"
@unknown default:
status = "prompt"
}
} else {
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.
for request in self.positionRequests {
// 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
if let location = locations.last {
let result = convertLocation(location)
request.resolve(result)
} else {
request.reject("Location service returned an empty Location array.")
// 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
if let location = locations.last {
let result = convertLocation(location)
request.resolve(result)
} else {
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
self.permissionRequests.removeAll()

@ -16,24 +16,24 @@ enum ScanKind: Decodable {
struct ScanOptions: Decodable {
let kind: ScanKind
let keepSessionAlive: Bool?
let message: String?
let successMessage: String?
var keepSessionAlive: Bool?
var message: String?
var successMessage: String?
}
struct NDEFRecord: Decodable {
let format: UInt8?
let kind: [UInt8]?
let identifier: [UInt8]?
let payload: [UInt8]?
var format: UInt8?
var kind: [UInt8]?
var identifier: [UInt8]?
var payload: [UInt8]?
}
struct WriteOptions: Decodable {
let kind: ScanKind?
var kind: ScanKind?
let records: [NDEFRecord]
let message: String?
let successMessage: String?
let successfulReadMessage: String?
var message: String?
var successMessage: String?
var successfulReadMessage: String?
}
enum TagProcessMode {

@ -34,7 +34,7 @@ public class NotificationHandler: NSObject, NotificationHandlerProtocol {
try? self.plugin?.trigger("notification", data: notificationData)
if let options = notificationsMap[notification.request.identifier] {
if options.silent {
if options.silent ?? false {
return UNNotificationPresentationOptions.init(rawValue: 0)
}
}

@ -34,13 +34,13 @@ enum ScheduleEveryKind: String, Decodable {
}
struct ScheduleInterval: Decodable {
let year: Int?
let month: Int?
let day: Int?
let weekday: Int?
let hour: Int?
let minute: Int?
let second: Int?
var year: Int?
var month: Int?
var day: Int?
var weekday: Int?
var hour: Int?
var minute: Int?
var second: Int?
}
enum NotificationSchedule: Decodable {
@ -67,13 +67,13 @@ struct Notification: Decodable {
var title: String
var body: String?
var extra: [String: String]?
let schedule: NotificationSchedule?
let attachments: [NotificationAttachment]?
let sound: String?
let group: String?
let actionTypeId: String?
let summary: String?
var silent = false
var schedule: NotificationSchedule?
var attachments: [NotificationAttachment]?
var sound: String?
var group: String?
var actionTypeId: String?
var summary: String?
var silent: Bool?
}
struct RemoveActiveNotification: Decodable {
@ -130,19 +130,19 @@ struct Action: Decodable {
var foreground: Bool?
var destructive: Bool?
var input: Bool?
let inputButtonTitle: String?
let inputPlaceholder: String?
var inputButtonTitle: String?
var inputPlaceholder: String?
}
struct ActionType: Decodable {
let id: String
let actions: [Action]
let hiddenPreviewsBodyPlaceholder: String?
var hiddenPreviewsBodyPlaceholder: String?
var customDismissAction: Bool?
var allowInCarPlay: Bool?
var hiddenPreviewsShowTitle: Bool?
var hiddenPreviewsShowSubtitle: Bool?
let hiddenBodyPlaceholder: String?
var hiddenBodyPlaceholder: String?
}
struct RegisterActionTypesArgs: Decodable {

@ -8,7 +8,7 @@ import UIKit
import WebKit
class PingArgs: Decodable {
let value: String?
var value: String?
}
class ExamplePlugin: Plugin {

Loading…
Cancel
Save