-
Notifications
You must be signed in to change notification settings - Fork 27
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
add RadarVerifyServer #417
Conversation
Companion app v2
@@ -23,10 +23,10 @@ jobs: | |||
run: xcodebuild clean build analyze test -workspace Example/Example.xcodeproj/project.xcworkspace -scheme RadarSDK -destination "platform=iOS Simulator,name=iPhone 15 Pro" | xcpretty | |||
|
|||
- name: Build archive for iPhone simulator (RadarSDK) | |||
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphonesimulator.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO | |||
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphonesimulator.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Swift support
@@ -9,7 +9,7 @@ | |||
<key>CFBundleIdentifier</key> | |||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | |||
<key>CFBundleInfoDictionaryVersion</key> | |||
<string>6.0</string> | |||
<string>5.0</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match SDK Swift version
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform' | ||
s.homepage = 'https://radar.com' | ||
s.author = { 'Radar Labs, Inc.' => 'support@radar.com' } | ||
s.platform = :ios | ||
s.source = { :git => 'https://github.com/radarlabs/radar-sdk-ios.git', :tag => s.version.to_s } | ||
s.source_files = ["RadarSDK/*.{h,m}", "RadarSDK/Internal/*.{h,m}", "RadarSDK/Include/*.h"] | ||
s.source_files = ["RadarSDK/*.{h,m,swift}", "RadarSDK/Include/*.h"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Swift support
s.module_name = 'RadarSDK' | ||
s.ios.deployment_target = '12.0' | ||
s.frameworks = 'CoreLocation' | ||
s.requires_arc = true | ||
s.license = { :type => 'Apache-2.0' } | ||
s.resource_bundles = {'RadarSDK' => ['RadarSDK/PrivacyInfo.xcprivacy']} | ||
s.swift_version = '5.0' | ||
|
||
s.subspec 'Verify' do |ss| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Telegraph dependency added to a subspec, not the main spec
/** | ||
The raw dictionary value of the token. | ||
*/ | ||
@property (nullable, copy, nonatomic, readonly) NSDictionary *rawDict; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the server to return the full token response
import Foundation | ||
import UserNotifications | ||
|
||
#if canImport(Telegraph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes Telegraph dependency optional
override init() { | ||
super.init() | ||
|
||
locationManager.delegate = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to keep app alive while server is running
response.headers["Access-Control-Allow-Methods"] = "GET, OPTIONS" | ||
} | ||
|
||
@objc func startServer(withCertData certData: Data, identityData: Data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server logic basically matches Mac app
|
||
} | ||
#else | ||
@objc(RadarVerifyServer) class RadarVerifyServer: NSObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"noop" version if Telegraph dependency not included
@@ -22,6 +22,7 @@ FOUNDATION_EXPORT const unsigned char RadarSDKVersionString[]; | |||
#import "RadarEvent.h" | |||
#import "RadarGeofence.h" | |||
#import "RadarGeofenceGeometry.h" | |||
#import "RadarLogger.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make RadarLogger.h
public to use it in Swift
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"startVerifyServer()"]; | ||
[RadarUtils downloadDataFromURL:[NSURL URLWithString:@"https://s3.us-east-2.amazonaws.com/app.radar-verify.com/mac/c.der"] completionHandler:^(NSData * _Nonnull certData, NSError * _Nonnull error) { | ||
[RadarUtils downloadDataFromURL:[NSURL URLWithString:@"https://s3.us-east-2.amazonaws.com/app.radar-verify.com/mac/id.p12"] completionHandler:^(NSData * _Nonnull identityData, NSError * _Nonnull error) { | ||
if (!certData || !identityData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to do these two downloads at the same time, but it's not that big of a deal since realistically it'll only be called once per session. (not worth the complication)
import Telegraph | ||
|
||
@objc(RadarVerifyServer) class RadarVerifyServer: NSObject, CLLocationManagerDelegate { | ||
@MainActor @objc static let sharedInstance = RadarVerifyServer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modifier @MainActor
forces the operations here to be done on the main thread. Is there a specific need for us to do all these non UI tasks on the main thread? This may be especially problematic if the app is running in the background and iOS imposes limitations on the app's main thread utilization (watchdog may decide to crash the app).
I also noticed that we already have semaphores in this implementation as well.
|
||
- name: Build archive for iPhone device (RadarSDK) | ||
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphoneos.xcarchive" -sdk iphoneos SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO | ||
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphoneos.xcarchive" -sdk iphoneos SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our offline discussion, we need to further verify that there are no complications in our SPM distribution which relies on the compiled XCFramework. Happy to assist in the verification process if required :)
startVerifyServer()
andstopVerifyServer()
, allowing customers to turn their Android app into a "companion app" (https://radar.com/documentation/fraud#web-and-desktop) fortrackVerified()
andstartTrackingVerified()
on mobilecanImport()
compiler directive inRadarVerifyServer.swift
and aRadarSDK/Verify
CocoaPods subspeclocation
background mode