iOS WKWebView does not load url - ios

I try to open webView, it works fine after first app download. But after several times clicking on it I get 401 error. The url works for Android and Web.
I tried to user SFSafariViewController and WKWebView, but result is the same.
Please help me to find the reason of this.
URL: https://milliard-pozdravlenij.gt.stoloto.ru/
// let controller = SFSafariViewController(url: url)
let controller = UIViewController()
let webView = WKWebView(frame: controller.view.frame, configuration: WKWebViewConfiguration())
controller.view.addSubviews(webView)
let request = URLRequest(url: url)
webView.load(request)
Error: this happens only with simulator
Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xed662242 5fb7c0a8 1bf3f783 33b5c275 ... 5cef5e61 5d97a96c }, _LSLine=478, WrongSimulatorHash={length = 32, bytes = 0x3190f8e7 217931fc b7f7be3d 298bbb9a ... 8472784b 30a84b1d }}

Related

How to resolve iOS SSO Auth failure with 1000 code?

I am going to implement SSO Auth to our enterprise application. I watched this WWDC talk. There is not enough information. I tried to use a simple code from this talk like this:
let url = URL(string: "realm://{{identity_server_url}")! //I checked this by changing realm: to https:.
let ssoProvider = ASAuthorizationSingleSignOnProvider(identityProvider: url)
let request = ssoProvider.createRequest()
request.requestedOperation = .operationLogin
let authController = ASAuthorizationController(authorizationRequests: [request])
authController.delegate = self
authController.presentationContextProvider = self
authController.performRequests()
self.ssoProvider = ssoProvider
self.authController = authController
But this is always failed with this error description:
Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)"

HTTP2 does not work with AVPlayer in Swift

Currently I'm trying to send the token via headers in Swift but looks like the problem consist in HTTP2.
Example:
AVURLAsset
let headers: [AnyHashable : Any] = [
"content-type": "application/json",
"authorization": "Bearer \(token)"
]
let videoAsset = AVURLAsset(url: videoUrl)
let subtitleAsset = AVURLAsset(url: vttURL, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
Error
Task <B2755FA5-132C-4EE2-A72F-269EAEA8035C>.<5> finished with error [100] Error Domain=NSPOSIXErrorDomain Code=100 "Protocol error" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <B2755FA5-132C-4EE2-A72F-269EAEA8035C>.<5>, _kCFStreamErrorDomainKey=1, NSErrorPeerAddressKey=<CFData 0x600000ff2300 [0x7fff80617cb0]>{length = 16, capacity = 16, bytes = 0x100201bb0de06a770000000000000000}, _kCFStreamErrorCodeKey=100, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <B2755FA5-132C-4EE2-A72F-269EAEA8035C>.<5>"
Related issues
https://forums.developer.apple.com/thread/105771
https://developer.apple.com/documentation/network/debugging_https_problems_with_cfnetwork_diagnostic_logging

Downloading multiple HLS audio files simultaneously fails

I have been trying to multiple HLS audio files together in iOS. The files are encrypted with a key. I need to fetch the key and store it locally for offline use. When I download a small number (2 or 3 files) of files simultaneously it works fine, but if I start downloading 10-15 files simultaneously most of them fails with the error message-
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could
not be completed" UserInfo={NSLocalizedFailureReason=An unknown error
occurred (-17377), NSLocalizedDescription=The operation could not be
completed}
I am getting error message from NSURLErrorDomain as well but they are rare.
The link of the approach which I am using to fetch the key for offline use is below -
Playing Offline HLS with AES-128 encryption iOS
Any help would be appreciated.
class AudioDownloader {
var productKey: String
var downloadUrl: URL
var downloadSession: AVAssetDownloadURLSession?
var fakeDownloadUrl: URL?
var downloadTask: AVAssetDownloadTask?
func downloadAudio() {
if downloadSession == nil {
let configuration = URLSessionConfiguration.background(withIdentifier: self.productKey)
downloadSession = AVAssetDownloadURLSession(configuration: configuration, assetDownloadDelegate: self, delegateQueue: OperationQueue.main)
configuration.shouldUseExtendedBackgroundIdleMode = true
configuration.httpShouldSetCookies = true
configuration.httpShouldUsePipelining = false
configuration.allowsCellularAccess = true
configuration.isDiscretionary = true
}
self.fakeDownloadUrl = self.convertToScheme(url: self.downloadUrl, scheme: "fakehttp")
let asset = AVURLAsset(url: self.fakeDownloadUrl!)
let loader = asset.resourceLoader
loader.setDelegate(self, queue: DispatchQueue(label: "dispatch2"))
self.downloadTask = downloadSession?.makeAssetDownloadTask(asset: asset, assetTitle: "assetTitle \(self.productKey)", assetArtworkData: nil, options: nil)!
self.downloadTask?.taskDescription = self.productKey
self.downloadTask?.resume()
}
}

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: Twitter update profile api giving error

I am trying to access update profile api of twitter. But its giving error.
let conn = WebserviceConnectionManager(serviceTokenId: "Twitter profile")
let url = NSURL(string: "https://api.twitter.com/1.1/account/update_profile.json")
let request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "POST"
let oAuthToken = FHSTwitterEngine.sharedEngine().accessToken.key
let oAuthTokenSecret = FHSTwitterEngine.sharedEngine().accessToken.secret
request.addValue(oAuthToken, forHTTPHeaderField:"oauth_token")
request.addValue(oAuthTokenSecret, forHTTPHeaderField:"oauth_token_secret")
conn.delegate = self
conn.startConnection(request)
Callback method gives me following error:
errors = (
{
code = 215;
message = "Bad Authentication data.";
}
);
Any help would be highly appreciated.
Since Twitter's API 1.1 does not allow access without authentication, because you have to use access tokens and secret keys; all requests must be made with a server-side script.
follow steps here and you will fixed your problem.

Resources