Skip to content

Commit

Permalink
Merge pull request #89 from prey/fix-iOS14
Browse files Browse the repository at this point in the history
Fix iOS 14
  • Loading branch information
patriciojofre authored Apr 8, 2021
2 parents 30edc6f + 587d109 commit b4a4531
Show file tree
Hide file tree
Showing 17 changed files with 426 additions and 208 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
Prey/.DS_Store
Prey.xcodeproj/xcuserdata/*
34 changes: 20 additions & 14 deletions Prey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@
/* Begin PBXCopyFilesBuildPhase section */
3BCE97002302191B00AF1AD4 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
buildActionMask = 8;
dstPath = "";
dstSubfolderSpec = 13;
files = (
3BCE972523021AB500AF1AD4 /* PreyNotify.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */

Expand Down Expand Up @@ -740,6 +740,7 @@
TargetAttributes = {
3B8283EC199198E6000E4545 = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = "";
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
Expand Down Expand Up @@ -767,6 +768,7 @@
};
3BCE971823021AB500AF1AD4 = {
CreatedOnToolsVersion = 10.2.1;
DevelopmentTeam = "";
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -1155,8 +1157,9 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2020080301;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Prey/Firebase",
Expand All @@ -1167,7 +1170,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Prey/GoogleAnalytics",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.1.8;
OTHER_SWIFT_FLAGS = "-D DEBUG";
PRODUCT_BUNDLE_IDENTIFIER = com.prey;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1188,8 +1191,9 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2020080301;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Prey/Firebase",
Expand All @@ -1200,7 +1204,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Prey/GoogleAnalytics",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.1.8;
PRODUCT_BUNDLE_IDENTIFIER = com.prey;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1253,21 +1257,22 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2020080301;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = PreyNotify/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.1.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.prey.PreyNotify;
PRODUCT_BUNDLE_IDENTIFIER = com.prey.NotifyPrey;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
Expand All @@ -1284,21 +1289,22 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2020080301;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = PreyNotify/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.1.8;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.prey.PreyNotify;
PRODUCT_BUNDLE_IDENTIFIER = com.prey.NotifyPrey;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +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/>
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
20 changes: 9 additions & 11 deletions Prey.xcodeproj/xcshareddata/xcschemes/Prey.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3B8283EC199198E6000E4545"
BuildableName = "Prey.app"
BlueprintName = "Prey"
ReferencedContainer = "container:Prey.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3B8283EC199198E6000E4545"
BuildableName = "Prey.app"
BlueprintName = "Prey"
ReferencedContainer = "container:Prey.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
9 changes: 4 additions & 5 deletions Prey/Classes/Alarm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ import MediaPlayer
class Alarm : PreyAction, AVAudioPlayerDelegate {

// MARK: Properties

var audioPlayer: AVAudioPlayer!

var checkVolumeTimer: Timer?

// MARK: Functions

// Prey command
override func start() {
PreyLogger("Playing alarm now")
Expand All @@ -35,7 +32,7 @@ class Alarm : PreyAction, AVAudioPlayerDelegate {
UIApplication.shared.beginReceivingRemoteControlEvents()
let volumeView = MPVolumeView()
volumeView.volumeSlider.setValue(1.0, animated: false)

// Check Volume level
checkVolumeTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(incrementVolume(_:)), userInfo: nil, repeats: true)

Expand Down Expand Up @@ -68,7 +65,9 @@ class Alarm : PreyAction, AVAudioPlayerDelegate {

let volumeView = MPVolumeView()
if volumeView.volumeSlider.value < 1.0 {
volumeView.volumeSlider.setValue(1.0, animated: false)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.01) {
volumeView.volumeSlider.setValue(1.0, animated: false)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Prey/Classes/FileRetrieval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class FileRetrieval : PreyAction {
// Check file_id
guard let file_id = self.options?.object(forKey: kOptions.file_id.rawValue) as? String else {
// Send stop action
PreyLogger("Send stop action on Check file_id")
self.stopActionFileRetrieval()
return
}
Expand All @@ -125,6 +126,7 @@ class FileRetrieval : PreyAction {
// Check name_file
guard let name_file = self.options?.object(forKey: kOptions.name.rawValue) as? String else {
// Send stop action
PreyLogger("Send stop action on Check name_file")
self.stopActionFileRetrieval()
return
}
Expand Down
3 changes: 1 addition & 2 deletions Prey/Classes/Geofencing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ class Geofencing: PreyAction, CLLocationManagerDelegate {
let attributes = geofenceZones.entity.attributesByName

for (attribute,description) in attributes {

if var value = (serverZonesArray as AnyObject).object(forKey: attribute) {
if var value = (serverZonesArray as AnyObject).value(forKey: attribute) {

switch description.attributeType {

Expand Down
2 changes: 1 addition & 1 deletion Prey/Classes/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Location : PreyAction, CLLocationManagerDelegate {

// Did Update Locations
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
PreyLogger("New location received")
PreyLogger("New location received on Location")

guard let currentLocation = locations.first else {
return
Expand Down
2 changes: 0 additions & 2 deletions Prey/Classes/PreyAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import Foundation
class PreyAction : Operation {

// MARK: Properties

var target: kAction
var command: kCommand
var options: NSDictionary?
var messageId: String?
var deviceJobId: String?
var triggerId: String?

var isActive: Bool = false

// MARK: Functions
Expand Down
2 changes: 1 addition & 1 deletion Prey/Classes/PreyDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PreyDevice {
type = (IS_IPAD) ? "Tablet" : "Phone"
os = "iOS"
vendor = "Apple"
model = UIDevice.current.deviceModel
model = UIDevice.current.deviceModel.rawValue
version = UIDevice.current.systemVersion
uuid = UIDevice.current.identifierForVendor?.uuidString
macAddress = "02:00:00:00:00:00" // iOS default
Expand Down
2 changes: 1 addition & 1 deletion Prey/Classes/ReportLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ReportLocation: NSObject, CLLocationManagerDelegate {

// Did Update Locations
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
PreyLogger("New location received")
PreyLogger("New location received on ReportLocation")

if !waitForRequest {
return
Expand Down
8 changes: 5 additions & 3 deletions Prey/Classes/ReportWifi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@

import Foundation
import SystemConfiguration.CaptiveNetwork
import NetworkExtension

class ReportWifi {

// MARK: Functions

// Get Network Info
class func getNetworkInfo() -> NSDictionary? {

var networkInfo = NSDictionary()

if let interfaces:CFArray = CNCopySupportedInterfaces() {

for i in 0..<CFArrayGetCount(interfaces) {

let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interfaces, i)
let rec = unsafeBitCast(interfaceName, to: AnyObject.self)
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString)
Expand All @@ -30,7 +31,8 @@ class ReportWifi {
}
}
}

return networkInfo
}

}
18 changes: 7 additions & 11 deletions Prey/Classes/Trigger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ class Trigger : PreyAction {
let attributes = trigger.entity.attributesByName

for (attribute,description) in attributes {

if var value = (serverTriggersArray as AnyObject).object(forKey: attribute) {

if var value = (serverTriggersArray as AnyObject).value(forKey: attribute) {
switch description.attributeType {

case .doubleAttributeType:
value = NSNumber(value: (value as AnyObject).doubleValue as Double)

default:
value = ((value as AnyObject) is NSNull) ? "" : value as! String
}
Expand All @@ -121,14 +117,14 @@ class Trigger : PreyAction {
}
}
// Check events
if let eventsArray = (serverTriggersArray as AnyObject).object(forKey: "automation_events") as? NSArray {
if let eventsArray = (serverTriggersArray as AnyObject).value(forKey: "automation_events") as? NSArray {
for eventItem in eventsArray {
let eventsTrigger = NSEntityDescription.insertNewObject(forEntityName: "TriggersEvents", into: context) as! TriggersEvents

if let type = (eventItem as AnyObject).object(forKey: "type") as? String {
if let type = (eventItem as AnyObject).value(forKey: "type") as? String {
eventsTrigger.type = type
}
if let info = (eventItem as AnyObject).object(forKey: "info") as? NSDictionary {
if let info = (eventItem as AnyObject).value(forKey: "info") as? NSDictionary {
do {
let data = try JSONSerialization.data(withJSONObject: info)
eventsTrigger.info = String(data: data, encoding: .utf8)
Expand All @@ -140,14 +136,14 @@ class Trigger : PreyAction {
}
}
// Check actions
if let actionArray = (serverTriggersArray as AnyObject).object(forKey: "automation_actions") as? NSArray {
if let actionArray = ((serverTriggersArray) as AnyObject).value(forKey: "automation_actions") as? NSArray {
for actionItem in actionArray {
let actionTrigger = NSEntityDescription.insertNewObject(forEntityName: "TriggersActions", into: context) as! TriggersActions

if let delay = (actionItem as AnyObject).object(forKey: "delay") as? Double {
if let delay = (actionItem as AnyObject).value(forKey: "delay") as? Double {
actionTrigger.delay = NSNumber(value:delay)
}
if let action = (actionItem as AnyObject).object(forKey: "action") as? NSDictionary {
if let action = (actionItem as AnyObject).value(forKey: "action") as? NSDictionary {
let localActionArray = NSMutableArray()
localActionArray.add(action)

Expand Down
Loading

0 comments on commit b4a4531

Please sign in to comment.