Problem Description
I am unable to dynamically set a Notification (toast) "message" attribute using the setting method "setMessage" from my controller. When called I get:
"Object #
has no method 'setMessage'"
Steps to reproduce
1. Create a new mobile project (Classic Titanium)
2. Add this code into app.js:
var toast = Ti.UI.createNotification({
//message:"Please Stand By",
duration: Ti.UI.NOTIFICATION_DURATION_LONG
});
toast.setMessage = "Please Stand By";
toast.show();
3. Run it into device.
Expected results
The toast showing.
Actual Results
When called I get:
"Object # has no method 'setMessage'"
Extra info (Workaround)
Putting "toast.setMessage = "Please Stand By";" or "toast.message = "Please Stand By";" dynamically, shows notification with blank message. The workaround is to set the message when it is created.
This was brought up on Slack and it appears to be an invalid ticket.
setMessage
is a function, and should therefore be invoked astoast.setMessage("Please Stand By")
. You are overwriting the function definition itself, which will not do anything to affect the notification. Once this code block has executed,setMessage
is then a String, which means calls to it as a function will error giving you the same message you cited. Alternatively, you could have usedtoast.message = "Please Stand By"
instead.[~iwhitfield] So your suggested usage does work? I'm wondering if the author just misspelled it. *EDIT*: If not, [this commit](https://github.com/appcelerator/titanium_mobile/compare/master...hansemannn:TIMOB-18276?expand=1#diff-577d9a684b3bdafb1dd7a4cfdafbd0af) might solve it. [~fmerzadyan] thoughts?
Verified the fix.
setMessage
works as expected. Appc Studio : 4.8.0.201611121409 SDK Version : 6.1.0.v20161129071600 Mac OS Version : 10.12 Xcode Version : Xcode 8.1 Build version 8B62 Appc CLI AND Appc NPM : {"NPM":"4.2.9-1","CLI":"6.0.0"} Ti CLI : 5.0.10 Alloy : 1.9.4 Node : v4.6.0 Google Nexus 6P - 6.0.0