Page 1 of 1

This initial setItem works in PC browser, but not my phone ? Any help >?

Posted: Sun Sep 15, 2013 5:56 am
by Walter Lee6162535

Hi,

I wrote below JS to help check if any setItem already there on the page Load event.
But it works in the PC browser, but not the phone.

When I tried it on the phone, it will spin for ever and no screen shown.

Do I miss any ? I just like to set some default values in setItem below if not yet set (e.g. 1st initial run),

var testmytime = localStorage.getItem('mytime');
if (!testmytime) {
localStorage.setItem('mytime','');
}

var testmynumber= localStorage.getItem('myphone');
if (!testmynumber) {
var tmp='13141314123';
localStorage.setItem('myphone', tmp);
}

var testmytext= localStorage.getItem('mytext');
if (!window.localStorage.mytext) {
var tmp2='I am sick !';
window.localStoarge.setItem('mytext',tmp2);
}

var timestamp = localStorage.getItem('mytime');
Appery('TimeStamp').text(timestamp);

var phonenumber = localStorage.getItem('myphone');
Appery('SMSPhoneNumber').text(phonenumber);

var mytext = localStorage.getItem('mytext');
Appery('SMSText').text(mytext);

var SMSText_form1= "sms:" + localStorage.getItem('myphone') + "?body=" + localStorage.getItem('mytext') + " 大約中风时间是 : " + localStorage.getItem('mytime');
Appery('resultSMS').text(SMSText_form1);


This initial setItem works in PC browser, but not my phone ? Any help >?

Posted: Sun Sep 15, 2013 9:31 am
by Maryna Brodina

Hello! Can you check are there any errors when you run app on desktop browser? Also could you clarify did you test app in device browser or you install app on device? What device and OS version you use?


This initial setItem works in PC browser, but not my phone ? Any help >?

Posted: Sun Sep 15, 2013 8:05 pm
by Walter Lee6162535

I worked around it with below code, seems working fine now.
So, no initialization issue now, but like to ask some other simple q.

Some q:

1/ can I use the same name for localStorage and variable ?
e.g. var mytime = localStorage.getItem('mytime'); ?

2/ can I just initialize the timestamp to any text below ?
Or time is a special thing ?

var timestamp = localStorage.getItem('mytime');
if ( timestamp == null ) {
var tmp='No timestamp logged yet, hit button to add timestamp';
localStorage.setItem('mytime', tmp);
var phonenumber = localStorage.getItem('myphone');javascript:void(0);
};
Appery('TimeStamp').text(timestamp);

3/ How can I send SMS to a group of phone numbers with native calls "sms:xxx" ?
When the stroke patient wants to send SMS, they may want to send it to 2 or 3 love ones for help. How to do this?

I found the native "sms: phone1, phone2?body=xxx" is not happy , so any example to send SMS to a group of phone easily ? It will be used in non-English community, so ATT SMS API is not something I can try now.

One idea is to see some example JS code to parse a list of phone number, e.g. in the user text box, if they enter "650-123-4567, 408-123-4567, 510-234-3456", then how can I parse it out to three phone numbers, so I can send SMS to each one later.

Thank you!

==============my current code below=============

var timestamp = localStorage.getItem('mytime');
Appery('TimeStamp').text(timestamp);

var phonenumber = localStorage.getItem('myphone');
if ( phonenumber == null ) {
var tmp='9999-9999';
localStorage.setItem('myphone', tmp);
var phonenumber = localStorage.getItem('myphone');
};

Appery('SMSPhoneNumber').text(phonenumber);

var mytext = localStorage.getItem('mytext');
if ( mytext == null ) {
var tmp2='I have early stroke signs and need urgent help ! ';
localStorage.setItem('mytext', tmp2);
var mytext = localStorage.getItem('mytext');
};

Appery('SMSText').text(mytext);

var SMSText_form1= "sms:" + localStorage.getItem('myphone') + "?body=" + localStorage.getItem('mytext') + " approx. stroke timestamp : " + localStorage.getItem('mytime');
Appery('resultSMS').text(SMSText_form1);


This initial setItem works in PC browser, but not my phone ? Any help >?

Posted: Sun Sep 15, 2013 9:00 pm
by maxkatz

1) Yes, you can do that.

2) Yes, you can do that.

Local storage is standard browser API. The best way to learn what's possible is here: https://developer.mozilla.org/en-US/d...

3) sms: -- is a standard protocol. If it doesn't support multiple phone numbers, that's just how it works. It's also possible different mobile OS have different support for sms:

If you need to send a message to multiple numbers, you could consider using SMS API such as from AT&T or Twilio.