JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

Line Break in Server Side Push notification

Hi there,

I can successfully send a push notification to my device using server side code.

I use:
PN.send(
"XXXXX-XXXX-XXXX-XXXX-XXXXXXX", //Push Notification API key
{"message": Variable1 + Variable1 } //Push notification message

I would like variable1 to be on a different line from Variable2.

Is this possible, and if so how?

thanks in advance.
James

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Line Break in Server Side Push notification

Hello Jimmy,

Could you please provide us some information about variables 1 and 2? Where do you get them? Maybe there is a possibility to make some variable 3 which will match your demands and send it?

JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

Line Break in Server Side Push notification

Hi Evgene,

The information variables 1 and 2 get their information from local storage. I don't think making a third variable (comprised of v1 and v2) will work, because I will face the same problem of them potentially being on the same line. They need to be separate as they are distinct pieces of information.

I have tried using the \n syntax but that didn't seem to work.

thanks
james

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Line Break in Server Side Push notification

Just checking ... You've tried the HTML "
"characters ( lol this site wants to take the characters and change them to a new line here ...

So... Try < followed by br and then followed by and remove my words followed by, the additional spaces and the word and.

and or the old dos cr-line feed characters.... Chr(10) and Chr(13) ( use them together ) ? These worked for HTML and text versions of an issue I needed to work with sendgrid email ... So thought either the HTML or the dos new line, carriage return might work for you.

Just a thought in passing ...

JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

Line Break in Server Side Push notification

Hi Bruce,

thanks very much for your suggestions. I have tried them all as suggested, but unfortunately they didn't work.

It doesn't recognize the
and just treats the Chr(10) and Chr(13) as regular text.

James

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Line Break in Server Side Push notification

Hi Jimmy,

I guess I should have looked at my code....

Try this:

http://www.w3schools.com/jsref/jsref_...

ie...

string1 + String.fromCharCode(13, 10) + string2 ;

best,
Bruce

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Line Break in Server Side Push notification

where string1 and string2 are your line1 and line2 respectively..

JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

Line Break in Server Side Push notification

Hi Bruce

I tried the following:

PN.send(
"XXXXXXXXXXX", //Push Notification API key
{"message": "Line1" + String.fromCharCode(13,10) + "Line 2" } //Push notification message
);

and it returned Line1 Line2.

the "String.fromCharCode(13,10)" didn't throw an error, it just didn't do anything.

thanks again and will gladly try any other thoughts you have.

Jimmy

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Line Break in Server Side Push notification

So ... Quick question then ... When you say it didn't recognize the ... The result was the same as the String.fromCharCode attempt ??

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Line Break in Server Side Push notification

The missing word was ""

Return to “Issues”