Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Siri shortcuts to enable/disable gps tracking #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
171 changes: 171 additions & 0 deletions Intents.intentdefinition
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?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>INEnums</key>
<array/>
<key>INIntentDefinitionModelVersion</key>
<string>1.2</string>
<key>INIntentDefinitionNamespace</key>
<string>1AigIl</string>
<key>INIntentDefinitionSystemVersion</key>
<string>23F79</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>15F31d</string>
<key>INIntentDefinitionToolsVersion</key>
<string>15.4</string>
<key>INIntents</key>
<array>
<dict>
<key>INIntentCategory</key>
<string>generic</string>
<key>INIntentConfigurable</key>
<true/>
<key>INIntentDescription</key>
<string>Starts Tracking Service</string>
<key>INIntentDescriptionID</key>
<string>8atNz2</string>
<key>INIntentEligibleForWidgets</key>
<true/>
<key>INIntentManagedParameterCombinations</key>
<dict>
<key></key>
<dict>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
<key>INIntentParameterCombinationUpdatesLinked</key>
<true/>
</dict>
</dict>
<key>INIntentName</key>
<string>StartTrackingService</string>
<key>INIntentParameterCombinations</key>
<dict>
<key></key>
<dict>
<key>INIntentParameterCombinationIsPrimary</key>
<true/>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
</dict>
</dict>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeConciseFormatString</key>
<string>yes</string>
<key>INIntentResponseCodeConciseFormatStringID</key>
<string>ZxxgPH</string>
<key>INIntentResponseCodeFormatString</key>
<string>yay</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>5l9bCc</string>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeConciseFormatString</key>
<string>no</string>
<key>INIntentResponseCodeConciseFormatStringID</key>
<string>fwaOIl</string>
<key>INIntentResponseCodeFormatString</key>
<string>nay</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>ziguoJ</string>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Start Tracking Service</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android we call these "Start service" and "Stop service". Can you please rename to make it consistent.

<key>INIntentTitleID</key>
<string>kVcJ5o</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>Do</string>
</dict>
<dict>
<key>INIntentCategory</key>
<string>generic</string>
<key>INIntentConfigurable</key>
<true/>
<key>INIntentDescription</key>
<string>Stops Tracking Service</string>
<key>INIntentDescriptionID</key>
<string>StpTr2</string>
<key>INIntentEligibleForWidgets</key>
<true/>
<key>INIntentManagedParameterCombinations</key>
<dict>
<key></key>
<dict>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
<key>INIntentParameterCombinationUpdatesLinked</key>
<true/>
</dict>
</dict>
<key>INIntentName</key>
<string>StopTrackingService</string>
<key>INIntentParameterCombinations</key>
<dict>
<key></key>
<dict>
<key>INIntentParameterCombinationIsPrimary</key>
<true/>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
</dict>
</dict>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeConciseFormatString</key>
<string>yes</string>
<key>INIntentResponseCodeConciseFormatStringID</key>
<string>StpOKh</string>
<key>INIntentResponseCodeFormatString</key>
<string>yay</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>StpYay</string>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeConciseFormatString</key>
<string>no</string>
<key>INIntentResponseCodeConciseFormatStringID</key>
<string>StpNOl</string>
<key>INIntentResponseCodeFormatString</key>
<string>nay</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>StpNay</string>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Stop Tracking Service</string>
<key>INIntentTitleID</key>
<string>StpTtl</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>Do</string>
</dict>
</array>
<key>INTypes</key>
<array/>
</dict>
</plist>
21 changes: 21 additions & 0 deletions TraccarClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
58FB0E542C35E708001D55B6 /* StartTrackingIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FB0E532C35E708001D55B6 /* StartTrackingIntent.swift */; };
58FB0E562C35E90A001D55B6 /* StopTrackingIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FB0E552C35E90A001D55B6 /* StopTrackingIntent.swift */; };
5E394EBE28A9CC7600396F33 /* BatteryStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E394EBD28A9CC7600396F33 /* BatteryStatus.swift */; };
5E716A271F63A0B100A2DBC3 /* DistanceCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E716A261F63A0B100A2DBC3 /* DistanceCalculator.swift */; };
5E716A291F63A45A00A2DBC3 /* RequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E716A281F63A45A00A2DBC3 /* RequestManager.swift */; };
Expand Down Expand Up @@ -65,6 +67,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
58FB0E4F2C35DF7F001D55B6 /* TraccarClient.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TraccarClient.entitlements; sourceTree = "<group>"; };
58FB0E532C35E708001D55B6 /* StartTrackingIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartTrackingIntent.swift; sourceTree = "<group>"; };
58FB0E552C35E90A001D55B6 /* StopTrackingIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopTrackingIntent.swift; sourceTree = "<group>"; };
5E394EBD28A9CC7600396F33 /* BatteryStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryStatus.swift; sourceTree = "<group>"; };
5E716A261F63A0B100A2DBC3 /* DistanceCalculator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DistanceCalculator.swift; sourceTree = "<group>"; };
5E716A281F63A45A00A2DBC3 /* RequestManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -154,6 +159,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
58FB0E522C35E6DE001D55B6 /* Intents */ = {
isa = PBXGroup;
children = (
58FB0E532C35E708001D55B6 /* StartTrackingIntent.swift */,
58FB0E552C35E90A001D55B6 /* StopTrackingIntent.swift */,
);
name = Intents;
sourceTree = "<group>";
};
CED4870F17DB1BF6007FCF57 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -190,6 +204,8 @@
CED4872117DB1BF6007FCF57 /* TraccarClient */ = {
isa = PBXGroup;
children = (
58FB0E522C35E6DE001D55B6 /* Intents */,
58FB0E4F2C35DF7F001D55B6 /* TraccarClient.entitlements */,
CE5899C71B115C9100ED70D2 /* Images.xcassets */,
CED4873317DB1BF6007FCF57 /* MainStoryboard.storyboard */,
CEF643241B919FFA00195CEA /* LaunchScreen.xib */,
Expand Down Expand Up @@ -389,10 +405,12 @@
files = (
CB7ED0801F6602CD00A33FCF /* Position.swift in Sources */,
CBAA0F7F1F68E807008BBBBE /* MainViewController.swift in Sources */,
58FB0E562C35E90A001D55B6 /* StopTrackingIntent.swift in Sources */,
CB7ED0821F661B4F00A33FCF /* PositionProvider.swift in Sources */,
CB4197991F67724F008F301C /* NetworkManager.swift in Sources */,
CB7ED0841F662BAF00A33FCF /* AppDelegate.swift in Sources */,
5E394EBE28A9CC7600396F33 /* BatteryStatus.swift in Sources */,
58FB0E542C35E708001D55B6 /* StartTrackingIntent.swift in Sources */,
5E716A2B1F63A60800A2DBC3 /* ProtocolFormatter.swift in Sources */,
CBCE82F21B8D265800A7318B /* TraccarClient.xcdatamodeld in Sources */,
CBAA0F7D1F68E14C008BBBBE /* StatusViewController.swift in Sources */,
Expand Down Expand Up @@ -522,6 +540,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TraccarClient/TraccarClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -692,6 +711,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TraccarClient/TraccarClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 59;
Expand Down Expand Up @@ -723,6 +743,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TraccarClient/TraccarClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
Expand Down
1 change: 1 addition & 0 deletions TraccarClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import UIKit
import CoreData
import Firebase
import IntentsUI

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PositionProviderDelegate {
Expand Down
2 changes: 2 additions & 0 deletions TraccarClient/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
20 changes: 20 additions & 0 deletions TraccarClient/StartTrackingIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import AppIntents
import SwiftUI

@available(iOS 16, *)
struct StartTrackingIntent: AppIntent {

static let title: LocalizedStringResource = LocalizedStringResource("Start Tracking Service", comment: "Title for start tracking intent")

func perform() async throws -> some IntentResult & ProvidesDialog {
var trackingController: TrackingController?
let userDefaults = UserDefaults.standard
if !userDefaults.bool(forKey: "service_status_preference") {
userDefaults.setValue(true, forKey: "service_status_preference")
await StatusViewController.addMessage(NSLocalizedString("Service created", comment: ""))
trackingController = TrackingController()
trackingController?.start()
}
return .result(dialog: .init(stringLiteral: NSLocalizedString("Service created", comment: "")))
}
}
20 changes: 20 additions & 0 deletions TraccarClient/StopTrackingIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import AppIntents
import SwiftUI

@available(iOS 16, *)
struct StopTrackingIntent: AppIntent {

static let title: LocalizedStringResource = LocalizedStringResource("Stop Tracking Service", comment: "Title for stop tracking intent")

func perform() async throws -> some IntentResult & ProvidesDialog {
var trackingController: TrackingController?
let userDefaults = UserDefaults.standard
if userDefaults.bool(forKey: "service_status_preference") {
userDefaults.setValue(false, forKey: "service_status_preference")
await StatusViewController.addMessage(NSLocalizedString("Service destroyed", comment: ""))
trackingController?.stop()
trackingController = nil
}
return .result(dialog: .init(stringLiteral: NSLocalizedString("Service destroyed", comment: "")))
}
}
8 changes: 8 additions & 0 deletions TraccarClient/TraccarClient.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,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">
<plist version="1.0">
<dict>
<key>com.apple.developer.siri</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions TraccarClient/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/pt.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";
2 changes: 2 additions & 0 deletions TraccarClient/zh.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
"Invalid server address" = "Invalid server address";
"Invalid server port" = "Invalid server port";
"Invalid frequency value" = "Invalid frequency value";
"Stop Tracking Service" = "Stop Tracking Service";
"Start Tracking Service" = "Start Tracking Service";