iOS - Firebase call neither sends error nor response - ios

When I delete the app and run the following code -> gives the response.
But when I run the same code second time -> I get no response.
FIRDatabase.database().reference().child("wall").child(userId).queryLimited(toLast: limit).observeSingleEvent(of: .value, with: { (snapshot) in
print("response")
}) { (error) in
print(error)
debugPrint(error.localizedDescription)
}
Sometimes it throws ->
NSURLSession/NSURLConnection HTTP load failed
(kCFStreamErrorDomainSSL, -9802)
And most of the time neither the response nor the error is thrown.
Any guesses what is wrong ?
P.S:
I've my plist as:
Most amazing thing is Firebase function call is not even sending error ??

Related

SKReceiptRefreshRequest always fails in Xcode 12.2 with .storekit configuration file

When I run the app with .storekit configuration file in Xcode 12.2 / iOS 14.2 Simulator, my SKReceiptRefreshRequest always fails, I get an error in my func request(_ request: SKRequest, didFailWithError error: Error) delegate method. Here are the logs:
# Printed by some Apple internal framework:
<SKReceiptRefreshRequest: 0x60000320d640>: Finished refreshing receipt with error: Error Domain=ASDServerErrorDomain Code=5002 "Unhandled exception" UserInfo={NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}
# Error logged by my code:
Failed to refresh app receipt: Error Domain=SKErrorDomain Code=0 "UNKNOWN_ERROR" UserInfo={NSLocalizedDescription=UNKNOWN_ERROR, NSUnderlyingError=0x600003c9a040 {Error Domain=ASDServerErrorDomain Code=5002 "Unhandled exception" UserInfo={NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}}}
I run the request as usual:
class ReceiptFetcher: NSObject {
func fetchReceipt() {
let request = SKReceiptRefreshRequest(receiptProperties: nil)
request.delegate = self
request.start()
}
}
extension ReceiptFetcher: SKRequestDelegate {
func requestDidFinish(_ request: SKRequest) {
LogVerbose("App receipt refreshed!")
// Handling success
}
func request(_ request: SKRequest, didFailWithError error: Error) {
LogVerbose("Failed to refresh app receipt: \(error)")
// Handling error
}
}
Everything worked fine until I upgraded Xcode to 12.2. Now it fails for both Run and Test actions.
I found nothing about ASDServerErrorDomain with code 5002. Any help on that?
Everything works again since Xcode 12.4. I hope they won't break this thing again...

How to get server error when a FIRStorageUploadTask fails with FIRStorageErrorCodeUnknown?

Refer to this Firebase doc. In part, it has this cryptic note:
uploadTask.observe(.failure) { snapshot in
if let error = snapshot.error as? NSError {
switch (StorageErrorCode(rawValue: error.code)!) {
...
case .unknown:
// Unknown error occurred, inspect the server response
break
default:
// A separate error occurred. This is a good place to retry the upload.
break
}
}
}
Great! I'd love to see the server error. But how do I do that? The error returns a code -13000 (FIRStorageErrorCodeUnknown) and an error string of "An unknown error occurred, please check the server response."
So how does one get the server error response???
From the source, there is additional detail in the NSDictionary object available on the NSError as error.userInfo.
For example, see https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseStorage/Sources/FIRStorageUploadTask.m#L204

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)

iOS App crashes when the service is closed

I've been writing an app with Swift 4 and it communicates with a service via RESTful API.
I have found some helpful code examples and everything works well as the service is running.
However, I could not handle the situation that the service is closed. I have tried try/catch blocks but they did not work well. Please check the code below firstly. It's the part of the communication. Basically it sends an email address to the service and gets a response as an activation code.
URLSession.shared.dataTask(with: request) { (data:Data?, response:URLResponse?, error:Error?) in
guard error == nil else {
// Some code
return
}
guard let responseData = data else {
// Some code
return
}
do {
guard let activation_response = try JSONSerialization.jsonObject(with: responseData, options: [])
as? [String: Any] else {
// Some code
return
}
guard let activation_code = activation_response["activation_code"] as? String else {
// Some code
return
}
// Some code, here, if it works fine.
} catch {
// Some code
return
}
}.resume()
When the service is closed, simply it will throw an error such as TCP connection failed. How can I handle it?
The error I get is something like below:
TheApp[4184:399699] TIC TCP Conn Failed [1:0x604000166600]: 1:61 Err(61)
2018-01-02 20:35:04.930874+0300 TheApp[4184:399699] Task <5ED49B16-BFDC-45A5-85F5-095C4FC4D84D>.<1> HTTP load failed (error code: -1004 [1:61])
2018-01-02 20:35:04.934352+0300 TheApp[4184:399698] Task <5ED49B16-BFDC-45A5-85F5-095C4FC4D84D>.<1> finished with error - code: -1004
It throws an exception and I can not catch it. I could not find how to do it. Thank you very much in advance for your help.

Firebase Anonymous Login fails after Xcode Update

My anonymous login for Firebase was working for months; however, when Xcode forced me to install some updates, it couldn't find some pods. After deleting those pods after running pod update, the project will now build; however, while attempting the anonymous login, I get this error:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
If I wait long enough, I get error messages like this:
[Client] Discarding message for event <private> because of too many unprocessed messages
Here is my login method:
func login(onCompletion: #escaping (NSError?) -> Void) {
print("authenticating user")
FIRAuth.auth()?.signInAnonymously(completion: { result, error in
guard error == nil else {
print("error while authenticating user")
onCompletion(loginError)
return
}
if let user = result {
self.defaults.set(user.uid, forKey: "uid")
onCompletion(nil)
} else {
onCompletion(loginError)
}
})
}
which is called in the root view controller's viewDidLoad.
I still don't know what the issue was, but it was specific to the project. I created a new project and pulled the code from github and now it works like normal.

Resources