[TIMOB-14717] BlackBerry: Crash with Ti.App.Properties.getString()
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Closed |
| Resolution | Cannot Reproduce |
| Resolution Date | 2013-07-31T16:02:25.000+0000 |
| Affected Version/s | Release 3.1.1 |
| Fix Version/s | n/a |
| Components | BlackBerry |
| Labels | blackberry, crash, properties |
| Reporter | Brent Barbata |
| Assignee | Pedro Enrique |
| Created | 2013-07-30T23:08:08.000+0000 |
| Updated | 2017-03-16T20:25:49.000+0000 |
Description
The following line (alone) will crash the BlackBerry simulator if the property cannot be found. (In this case, the property name is "Credentials".)
var storedCredentials = JSON.parse(Ti.App.Properties.getString("Credentials"));
However, if we set the property/value pair using setString() and then try getString(), everything works fine. For example, this will work:
// Build json string
oCredentials = new Object();
oCredentials.username = "some username";
oCredentials.password = "some password";
var stringCredentials = JSON.stringify(oCredentials);
// Save credentials
Ti.App.Properties.setString("Credentials", stringCredentials);
// Read the credentials
var storedCredentials = JSON.parse(Ti.App.Properties.getString("Credentials"));
I do not see a crash, I see message
This appears when trying to JSON.stringify an undefined value. Same thing happens in a node.js console:> JSON.parse(undefined) SyntaxError: Unexpected token u at Object.parse (native) at repl:1:7 at REPLServer.self.eval (repl.js:109:21) at Interface.<anonymous> (repl.js:248:12) at Interface.EventEmitter.emit (events.js:96:17) at Interface._onLine (readline.js:200:10) at Interface._line (readline.js:518:8) at Interface._ttyWrite (readline.js:736:14) at ReadStream.onkeypress (readline.js:97:10) at ReadStream.EventEmitter.emit (events.js:126:20) >Closing ticket as BlackBerry is no longer supported by us.