Firebase Crashlytics Custom Log Only Log Single Line - ios

Recently my app has been crashing while trying to deserialize the JSON sent from the server and unfortunately the server doesn't record any log so I can't verify with them. So I decided to log the JSON response for this particular Api, I know that it's a bad practice to log server response but it's the only way I could try to identify the issue, the response for this api is not that long so I think it should be fine.
The issue comes in when I tried to reveal the log and found out it only shows one line in the firebase console as below:
raw response : {
The result I was expecting were something as below,vit shows up nicely in the debug console while developing using CLSNSLogv. I thought it will be the same in firebase console too but it was not the case.
raw response : {
success ={
Status = OK;
Object1 = "test"
Object2 = "test2"
};
}
Below is the code for logging, "value" is a dictionary as below:
value: [String : AnyObject]?
CLSLogv("raw response : %#", getVaList([value!]))
Appreciate your help

This is a Crashlytics issue, my team has been experiencing this issue lately. We were printing dictionary using CLS_LOG in ObjC and we've noticed that it displays only first line of the dictionary.
I've contacted Crashlytics support team, and a guy from there confirmed a bug and told me that he contacted their engineering team for a fix.
You can change the way of logging for now to display everything in single line, or log by log, or you can wait for a fix.

You can convert the response to JSON using JSONSerialization and then remove all the carriage returns so that it's all one line. If you log that modified value it should appear correctly in the Crashlytics logs.

Related

SwiftUI Firebase Auth Error "Paths must not contain // in them"

In my SwiftUI app I suddenly started getting this error once my user logs in (I use Firebase Phone Auth)". It happens right as soon as I do this:
let db = Firestore.firestore()
db.collection("user").document(user.UID)
.getDocument { document, err in
This is the error, the app crashes totally:
Invalid path (com.googleusercontent.apps.178114301509-gvnp7pp9tm6jq9s4rridgoae9glog8nj://firebaseauth/link?deep_link_id=https%3A%2F%2Fgigas-4f2dd.firebaseapp.com%2F__%2Fauth%2Fcallback%3FauthType%3DverifyApp%26recaptchaToken%3DTOKEN%26eventId%3Dmwkcoldfan). Paths must not contain // in them."
I tried reverting back my project with Github but I cannot find whatever happened that started all this. I don't even know what Path is the debugger talking about. I have seen people in other cases saying that maybe it is the id being empty so a / and another / collapse into a // making it causing such an error but it is not my case since I am sure the id is not empty.

Parse Livequery changes not printing when there's an update

When I started working with parse live query I knew from the beginning it would be a challenge. Seeing that there were muiple ways to create a live query. When I had the set up the server early on, the bit of code I used to listen for updates looked like this:
let liveQueryClientMessage = ParseLiveQuery.Client()
qMessages.whereKey("toUser", equalTo: (PFUser.current()?.objectId!)! as String)
messageSubscription = liveQueryClientMessage.subscribe(qMessage).handle(Event.created){ _, message in
//prepare a local notification alert
print("object updated")
}
This however, no longer seems to function properly. So I looked at the parse live query docs to see if there was a working example and found that this gets the server to "Create new client: " with this code:
let qMessages = PFQuery(className: "Messages")
qMessages.whereKey("toUser", equalTo: (PFUser.current()?.objectId!)! as String)
let subscription = Client.shared.subscribe(qMessages)
subscription.handle(Event.updated){ query, event in
print("object updated")
}
But I am unable to get the print message to display... Am I missing something? I'm using the latest version of parselivequery I believe:
pod 'ParseLiveQuery'
UPDATE1: So I tried to rebuild the server and the issue still seems to persist. I'll try and make use of a parse query and see if its the filter...
UPDATE2: I rolled back the version of the podfile just in case it was an issue with just grabbing the lastest master branch. No fix yet...
The solution to fixing this issue was related to where everything was defined. Refer to the awnser to this stackoverflow question: Parse Cloud - LiveQueries - iOS Client doesn't work There's sufficient explanation there too.

Firebase childbyAutoId returns the same strange key every time

When using childByAutoId, something really strange happens. Instead of getting a unique id, I get the following key every time:
-------------------0
I know keys are generated with client side timestamps, so I tried running my code through the iOS simulator and an actual device, same result though.
I don't do anything interesting in my code, but here it is for reference:
func sendRandomMessage() {
let firebaseRootRef = Firebase(url:firebaseRootUrl)
let newMessageRef = firebaseRootRef.childByAutoId()
println(newMessageRef.key)
}
I'm using Firebase 2.3.0
There was a bug in the Firebase SDK for iOS 2.3.0 that caused this problem.
It has been fixed in 2.3.1. See https://www.firebase.com/docs/ios/changelog.html

iOS POST doesn't work on HTTPS

I have some code that works fine with HTTP, but fails with (null) value returned from the NSJSONObjectserialization-thing on HTTPS.
I tried converting the received data to string, and it comes out to log as valid JSON. I validated it also to be sure. All good. The HTTPS certificate is valid, but I did try implementing the callbacks for invalid certs also, no change.
The EXACT same configuration works perfectly on HTTP, and if I go to the browser and input the same POST (I even tried removing the POST and just have the server return JSON no matter what you input) I get valid JSON also.
I tried converting the received data to an array and grab the first object in the array - didn't work either. I tried changing http headers in different configurations (application/json) etc. No dice.
Error code is Cocoa 3840. This error means, as far as I can tell, invalid JSON. HOW is this possible? It says character 3 is bad?
Any suggestions? I Googled the best I could but all I can find is "https and http should work in the same way" more or less.
Certificate is validated by RapidSSL.
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:_responseDataNews options:kNilOptions error:&error];
_responseDataNews is the object that gets filled by didReceiveData delegate - and this exact config works on HTTP. What the #€%*# am I doing wrong here? It's driving me insane.
Exact error is:
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0xbb2cde0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
If I enable fragment option:
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 3.) UserInfo=0xb939ab0 {NSDebugDescription=Invalid value around character 3.}
JSON looks like: {"r":1,"n":"Text here"}
And no, "text" contains no funky characters. This is the actual JSON value I'm testing.
Edit: NSLog of the data object reveals:
efbbbfef bbbfefbb bfefbbbf efbbbf7b 22687322 3a5b7b22 75736572 223a2254
65737465 73656e22 2c227363 6f726522 3a223233 3032227d 5d7d
(with JSON: {"hs":[{"user":"Testesen","score":"2302"}]} )
Edit: ... Okay, as it turns out, now it doesn't work on HTTP either, so it must be after changing the SSL setup or something on the server that it broke!? HTTP returns the exact same (invalid) data object :(
You report that the NSData for your string is:
<efbbbfef bbbfefbb bfefbbbf efbbbf7b 22687322 3a5b7b22 75736572 223a2254
65737465 73656e22 2c227363 6f726522 3a223233 3032227d 5d7d>
The ef bb bf is a byte order mark for a UTF-8 string. But if you have a BOM, you should have only one, and you have five of them.
If you're creating this response programmatically, you may have some server function that is called multiple times that is adding this BOM repeatedly. The BOM should appear only once (if at all), and the fact that it's appearing multiple times indicates a problem in your server code.
If you created this file manually, you might want to edit the hex data. Use whatever hex editor you want to fix this. For example, if you want to edit this file with Xcode, you can add it to your Xcode project and then right click on the file and choose "Open as..." - "Hex".
Okay - it turns out this had nothing to do with HTTPS anyway.
For some reason I cannot really understand, my php script was prefixing invalid characters after I restructured it to use only 1 .php file that responds to POST, includes all other .php files and returns the appropriate function depending on what you POST - of course I tried to just make it call one of the functions without POSTing anything, so that I could exclude POST errors from troubleshooting.
After I changed it so I request the specific file depending on what I want to do on the server - get news, get users, get score, whatever, like server.com/getscore.php instead of just server.com + POST data to get score, it works without issue and the JSON response is valid.
I don't really know how .php messes this up, but SOMETHING goes wrong. I tried enabling "Show all characters" in Notepad++, but I don't see anything funky anywhere. I made sure all .php files are encoded in UTF-8 also.

GAIDictionaryBuilder fails for NSNumber values

I am trying to send commerce transaction data to google analytics on iOS with V3 SDK. I am building the data dictionary using GAIDictionaryBuilder class provided by Google (which is not open source unfortunately). For both createTransactionWithId and createItemWithTransactionId calls, my NSNumber values (revenue, price, etc.) are failing to be added to dictionary data properly. Here is the sample code:
NSMutableDictionary* test = [[GAIDictionaryBuilder createTransactionWithId:(NSString *)transactionId
affiliation:(NSString *)affiliation
revenue:(NSNumber *)revenue
tax:(NSNumber *)tax
shipping:(NSNumber *)shipping
currencyCode:(NSString *)currencyCode] build];
NSLog(#"revenue: %#", revenue);
NSLog(#"TR data: %#", test);
// if I explicitly set the value, IT WORKS!!!!
[test setObject:revenue forKey:#"&tr"];
NSLog(#"TR data FIXED??: %#", test);
In the output, I see revenue correctly, then when logging test dictionary I see the following line corresponding to revenue data:
"&tr" = "<null>";
Then, for the manual fix attempt, I see
"&tr" = "15.25";
as expected.
Here are some clues:
I use the same code in a different project compiled in a different OSX machine without any issues like this.
The transactions are in TRY (Turkish Lira), I suspect Google is trying to fix the separator (',' in Turkish vs '.' everywhere else), but as said above, the other app is also using TRY.
So the question is, why "<null>", why and how does it fail to convert a proper NSNumber to this bizarre value?
Eventually, I fixed the issue by working around it. I assigned the NSNumber to a new one (by getting its floatValue) and it seemed to fix the null values.
By the way, google analytics library version 3.07 readme mentions a similar issue as fixed however neither 3.03 nor 3.07 actually fixed my problem.

Resources