malformed number error in push notification ios - ios

I am making an ios application and using push notifications. When I copy and paste the following notificatiom everything works fine.
{"aps":{"alert":"Temperature reached to 37.3.Board: raspberrypi.Time: 2015-07-09T14:02:02.0000000","badge":1,"sound":"default"},"AdditionalInfo":"","SensorType":"Temperature"}
When I use the following notification it says payload has been pushed, but I never receive the notification.
{"aps":{"alert":"Humidity reached to 69.0.Board: onshore_raspberrypi.Time: 2015-07-09T10:31:00.0000000","badge":1,"sound":"default"},"AdditionalInfo":"","SensorType”:”Humidity”}
And at the bottom right corner I get the following message: "malformed 187". The link to the screen shot is below.
Screen shot of push notification
What does malformed mean? And how I can fix it?

Your second string is an invalid JSON string. Use a site like this to validate.
You had curly quotation marks instead of straight quotation marks in some places. I removed and replaced them with the correct ones. The following JSON should work!
{"aps":{"alert":"Temperature reached to 37.3.Board: raspberrypi.Time: 2015-07-09T14:02:02.0000000","badge":1,"sound":"default"},"AdditionalInfo":"","SensorType":"Humidity"}

Related

Firebase Crashlytics Custom Log Only Log Single Line

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.

Setting "origin" in youtube-ios-player-helper breaks programatic functionality

Using the YouTube iOS Player Helper library (https://github.com/youtube/youtube-ios-player-helper downloaded on 2015-06-16), if I add the line:
#"origin": #"example.com",
before:
#"modestbranding": #1
at line 30 in SingleVideoViewController.m, then the programatic controls no longer function to affect the video, and the progress bar no longer updates. Additionally, very few of the status messages are being shows/received.
I assume/hope "origin" would show up in analytics, to signify source, which is why I'm setting it.
Is there a specific format this text needs to be in, or something else I should be setting?
I'm cross posting this issue here as I have got no response to the GitHub issue
https://github.com/youtube/youtube-ios-player-helper/issues/121
You are not passing in a valid url for the origin parameter.
Try #"origin": #"https://example.com" or #"origin": #"http://example.com". Note the http(s)://.

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.

How to print PDF file already opened in QLPreviewController using print button?

I get binary array then convert it and save in Documents folder and then showed in QLPreviewController. I have seen the right button on the tool bar of QLPreviewController.
I want to print that is in the preview right now. But when i tab error occurs
*** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIDocumentInteractionController.m:960
Also please guide me about printing that document. I have read about UIPrintInteractionController.
Why this Error occurs because you have set the URL wrong.
You are setting url like that;
/Users/akrama2/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/59356D13-C021-431F-A5D2-B8CD16E2B301/Documents/Application_Report.pdf
Where as UIDocumentationController task URL as:
file://localhost/Users/akrama2/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/59356D13-C021-431F-A5D2-B8CD16E2B301/Documents/Application_Report.pdf
This minor mistake will made you mad ;)

Apple push notifications and Emoji characters

I recently found this very interesting article on APNS and Emoji characters: EASY APNS - Just for fun
It contains a list with all supported Emojis. However, I couldn't get them to display in my push notifications. All I get is the code, not the image. For example, if I add \ue415 (a smiley) to my message, I never see the image, just the code.
Any idea what I'm doing wrong?
NSString *emoji = [NSString stringWithFormat:#"%C", 0xe415];
check out this site http://code.iamcal.com/php/emoji/
he does the emoji in php.
i use this command to achieve a emoji on the iphone.
emoji_unified_to_softbank("\xee\x80\xac");
Q
If you happen to be using Rubymotion for iOS dev the you can use the softbank code converted like this:
softbank code: U+E04A
Rubymotion string sent as push: "This is a sun with rays emoji \ue04a"

Resources