Error Loading objects from a Web Server - ios

I use this code to get my objects on web like the Ikea app, but it's not working and gives me the error below.
func loadModel() {
let virtualObjectURL: URL!
virtualObjectURL = URL(string: "https://example.com/\(modelName).\(fileExtension)")
let virtualObjectScene = try! SCNScene(url: virtualObjectURL)
let wrapperNode = SCNNode()
for child in virtualObjectScene.rootNode.childNodes {
child.geometry?.firstMaterial?.lightingModel = .physicallyBased
child.movabilityHint = .movable
wrapperNode.addChildNode(child)
}
self.addChildNode(wrapperNode)
modelLoaded = true
}
It looks like an SSL certificate error, but I tried AllowArbitaryLoads and it didn't work.
Must I use MySQL or something? I feel like if I don't have any SSL certificate errors, it gives me another error.
2017-11-15 18:18:05.669124+0300 ARKitProject[2908:2157180] Strict Trust Evaluation yielded status(-9802) for [1:0x1c416f780]
2017-11-15 18:18:05.669206+0300 ARKitProject[2908:2157180] TIC SSL Trust Error [1:0x1c416f780]: 3:0
2017-11-15 18:18:05.669430+0300 ARKitProject[2908:2157180] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
2017-11-15 18:18:05.669469+0300 ARKitProject[2908:2157180] Task <DF717E27-6EC4-4800-8B1A-01D6B796CFE7>.<0> HTTP load failed (error code: -1200 [3:-9802])
2017-11-15 18:18:05.670112+0300 ARKitProject[2908:2157268] NSURLConnection finished with error - code -1200

Related

BrainTree DropIn credit card example

I am trying to integrate BrainTree with ios using DropIn UI.
I succeeded to show the UI and when I use the test card
Number: 4111111111111111
Exp: 09/2020
It shows message
"Please review your information and try again"
let request = BTDropInRequest()
request.amount = "100"
request.paypalDisabled = true
request.shouldMaskSecurityCode = true
let dropIn = BTDropInController(authorization: tokenizationKey, request: request)
{ (controller, result, error) in
if (error != nil) {
print("ERROR = \(error?.localizedDescription ?? "")")
} else if (result?.isCancelled == true) {
print("CANCELLED")
} else if let result = result {
print("Payment Description = \(result.paymentDescription)")
print("paymentOptionType = \(result.paymentOptionType)")
print("paymentMethod = \(result.paymentMethod?.type ?? "")")
print("isCancelled = \(result.isCancelled)")
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType = .
}
controller.dismiss(animated: true, completion: nil)
}
viewController.present(dropIn!, animated: true, completion: nil)
And here is the log when I click on Add Card
-canOpenURL: failed for URL: "com.venmo.touch.v2://x-callback-url/vzero/auth" - error: "This app is not allowed to query for scheme com.venmo.touch.v2"
TIC TCP Conn Failed [25:0x28008b3c0]: 12:8 Err(-65554)
Task .<2> HTTP load failed (error code: -1003 [12:8])
Task .<2> finished with error - code: -1003
TIC TCP Conn Failed [26:0x2800889c0]: 12:8 Err(-65554)
Task <650E9BB8-3AF6-4076-A6C4-977D0435B161>.<5> HTTP load failed (error code: -1003 [12:8])
Task <650E9BB8-3AF6-4076-A6C4-977D0435B161>.<5> finished with error - code: -1003
[BraintreeSDK] WARNING Failed to flush analytics events: A server with the specified hostname could not be found.
It seems that sandbox doesn't work on a real device when I switched to a simulator, request succeeded after adding a credit card details.
After changing to the production environment the same problem existed, After a several tries I changed from Wifi to LTE as connection in my iPhone device, and it worked! it seems that my ISP has no DNS for production Braintree backend

Firebase Task finished with error - code: -1200

I am unable to access data from Firebase storage on my iOS app on my current connection. When I connect to a VPN, it allows me to connect and download data from Firebase Storage normally. I have also tried to allow arbitrary loads but to no use. Any suggestions?
The following is the code:
let tempImageRef = storage.child("CoverArt/Issue15.jpg")
tempImageRef.getData(maxSize: 1*1000*1000) { (data, error) in
if (error == nil)
{ //Do something }
else { print(error!.localizedDescription) } }
The following is the error:
Task <D343DC6F-2D37-4246-A0BA-4044BF36C83D>.<1> finished with error - code: -1200 An unknown error occurred, please check the server response.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

TIC SSL Trust Error while accessing data from https url

I have tried to access data from a https url by following.
DispatchQueue.global(qos: .background).async {
let stringURL = "https://192.168.104.91:8443/update_info.xml"
let url = URL(string: stringURL)
var data:Data? = nil
do {
data = try Data(contentsOf: url!)
} catch {
print(error.localizedDescription)
}
}
But i am getting following error.
2018-03-21 12:49:35.529949+0600 AppName[704:205346] TIC SSL Trust Error [1:0x1c0171a00]: 3:0
2018-03-21 12:49:35.541223+0600 AppName[704:205346] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2018-03-21 12:49:35.541283+0600 AppName[704:205346] Task <7D4A1063-B946-4588-830A-CE73AF5B4995>.<0> HTTP load failed (error code: -1202 [3:-9813])
2018-03-21 12:49:35.541771+0600 AppName[704:205344] NSURLConnection finished with error - code -1202
The file “update_info.xml” couldn’t be opened.
Any suggestions ?

iOS Mapkit get directions works in Playground , but not in app update:

Here's a simple app with a VC that asks for directions from MapKit. It compiles and executes, but doesn't work properly. Below is the complete code, followed by the log results:
//
// ViewController.swift
// MapKitDirections
//
import UIKit
import MapKit
class ViewController: UIViewController {
func getDistance() {
let source = MKMapItem(placemark: MKPlacemark(
coordinate: CLLocationCoordinate2DMake(-41.27, 173.28), addressDictionary: nil))
let destination = MKMapItem(placemark: MKPlacemark(
coordinate: CLLocationCoordinate2DMake(-41.11, 173), addressDictionary: nil))
let directionsRequest = MKDirectionsRequest()
directionsRequest.source = source
directionsRequest.destination = destination
let directions = MKDirections(request: directionsRequest)
print("before: directions.calculateDirectionsWithCompletionHandler")
directions.calculateDirectionsWithCompletionHandler({(response, error) in
print("\nwithin: completion handler\n")
print("\n error: \(error)")
print("\n response: \(response?.routes.first?.distance)")
})
print("after: directions.calculateDirectionsWithCompletionHandler\n")
}
override func viewDidLoad() {
super.viewDidLoad()
getDistance()
}
}
before: directions.calculateDirectionsWithCompletionHandler
after: directions.calculateDirectionsWithCompletionHandler
2015-07-03 21:32:09.536 MapKitDirections[293:69261] CFNetwork SSLHandshake failed (-9824)
2015-07-03 21:32:09.541 MapKitDirections[293:69261] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
2015-07-03 21:32:09.545 MapKitDirections[293:69218] PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x12f660710 {_kCFStreamErrorCodeKey=-9824, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x12f713a00 "An SSL error has occurred and a secure connection to the server cannot be made.", NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://gsp-ssl.ls.apple.com/directions.arpc, NSErrorFailingURLStringKey=https://gsp-ssl.ls.apple.com/directions.arpc, _kCFStreamErrorDomainKey=3}
within: completion handler
error: Optional(Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x12f660710 {_kCFStreamErrorCodeKey=-9824, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x12f713a00 "An SSL error has occurred and a secure connection to the server cannot be made.", NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://gsp-ssl.ls.apple.com/directions.arpc, NSErrorFailingURLStringKey=https://gsp-ssl.ls.apple.com/directions.arpc, _kCFStreamErrorDomainKey=3})
response: nil
This question was previously posted as "iOS Mapkit get directions works in Playground , but not in app". but #matt wanted to see the code within an app instead of a Playground.
Admittedly, this is a very simple app -- that does nothing but attempt to get directions. I did it this way to focus on the issue and avoid the distraction of unnecessary code.
FWIW, the same code executed in a Playground returns the directions, as shown in the original post.

How can I get source code from URL with SSL using Swift?

I am trying to read a source code of a site from its URL.
Below is my code.
let myURLString = "https://theUrlOfTheSite"
let myURL = NSURL(string: myURLString)
var error: NSError?
let myHTMLString = String(contentsOfURL: myURL!, encoding: NSUTF8StringEncoding, error: &error)
if let error = error {
println("Error : \(error)")
} else {
println(myHTMLString)
}
It works for some site, but not for others. I get the following error
2014-12-21 19:11:54.032 MyPlayground[2912:345862] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807)
Error : Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)"
I think it's because the site is https, not http. (I don't really know about this stuff but..SSL something??)
So my question is, what should I do to make my code work??
I searched for hours but I'm new to iOS and Swift, so no progress.
Do I have to make NSURLConnection or something? Because all I want to do is get the source code. Must be a simple job I guess..
Any help will be appreciated. Thanks in advance.

Resources