smartcar / ios-sdk Goto Github PK
View Code? Open in Web Editor NEWSmartcar SDK for iOS.
Home Page: https://smartcar.github.io/ios-sdk/
License: MIT License
Smartcar SDK for iOS.
Home Page: https://smartcar.github.io/ios-sdk/
License: MIT License
Changing the displayName for mock to "mock" should do it
So its easier to show that the SDK worked
With something more generic and copyright-free
Tests use the old smartcar://
scheme
Include placeholders, and describe handling in a readme file
Now Trunk isn’t exactly an account; it’s a session. So basically there is no need for a password, just an email.
The process is incredibly simple:
pod trunk register <Your Email>
You should quickly get an email from CocoaPods to verify your ‘session’. Verify your account by clicking the link provided in the email. CocoaPods will greet you with friendly message: ACE, YOU ARE SET UP!
Hello,
I have noticed the newly added state
parameter for requests is not working properly:
""
, cf SmartcarAuth.swift:45
SFSafariViewController
resumeAuthorizationFlow(with url: URL)
is called the given url doesn't contain the state
parameter anymore which causes a crash at let state = query?[1].value
I also tried setting it to " "
but it prevents a valid URL from being created because it is not escaped properly, which causes a crash in:
let safariVC = SFSafariViewController(url: URL(string: authorizationURL)!)
Setting it to "%20"
fixes the crash above, but the test in resumeAuthorizationFlow(with url: URL)
doesn't handle escaping right and we end end comparing " "
and "%20"
.
I set it to a random UUID string which seems to have fixes the problem.
I would highly recommend using a valid default value, or manage the case where the value is empty. To prevent crashes I would also suggest refactoring resumeAuthorizationFlow(with url: URL)
as follows :
public func resumeAuthorizationFlow(with url: URL) throws -> String {
let urlComp = URLComponents(url: url, resolvingAgainstBaseURL: false)
guard let query = urlComp?.queryItems else {
// declare a new error maybe?
throw AuthorizationError.missingURL
}
guard let code = query.filter({ $0.name == "code" }).first?.value else {
throw AuthorizationError.missingURL
}
guard let state = query.filter({ $0.name == "state" }).first?.value else {
throw AuthorizationError.missingState
}
if state != self.request.state {
throw AuthorizationError.invalidState
}
return code
}
Using query parameter names instead of probable indexes guarantees to find the right element if it exists, and this will prevent further crashes when accessing index out of bounds.
Thanks for considering,
Stan
I found that there is Vehicle Simulator new ferature but how can i config it when init SmartcarAuth?
It seems that calling
viewController.present(safariVC, animated: true, completion: nil)
leads to a Safari showing a white screen, but changing to the following works:
UIApplication.shared.keyWindow?.rootViewController?.present(safariVC, animated: true, completion: {
//
})
It looks like we have an incorrect access level of variables of AuthorizationError
class as well as the inner ErrorType
enum.
This is the current implementation:
@objc public class AuthorizationError: NSObject, Error {
enum ErrorType {
...
}
var type: ErrorType
var errorDescription: String?
var vehicleInfo: VehicleInfo?
init(type: ErrorType, errorDescription: String? = nil, vehicleInfo: VehicleInfo? = nil) {
...
}
}
This implementation doesn't let to know anything about the instance of the AuthorizationError
class because all variables have the internal access level.
@allisonc07 Looks like the README and/or the whole package didn't get updated/deployed properly. I notice launchAuthFlow Parameters doesn't have the new param. Please investigate. https://cocoapods.org/pods/SmartcarAuth
When a user denies access to an application, the SDK returns an AuthorizationError
to the completion
handler. There are a few different cases this error is returned as we can see in the callback handling code below:
ios-sdk/SmartcarAuth/SmartcarAuth.swift
Lines 143 to 161 in 2dd06de
There is no documentation around this error. In addition, the detailed error_description
returned by the Smartcar Connect flow is also not surfaced.
Since XCode now supporting swift package manager natively, I've been migrating all my dependencies from cocoapods to it. One exception is SmartcarAuth, which doesn't yet support it.
The change should be minimal, just adding the manifest file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.