Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18276] UI.Notification.setMessage function is not found even though it is documented

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-11-28T23:37:21.000+0000
Affected Version/sRelease 3.4.0, Release 3.4.1
Fix Version/sRelease 6.1.0
ComponentsAndroid
LabelsTCSupport, android, notification
ReporterDan Roberts
AssigneeFarzad Merzadyan
Created2014-10-15T09:29:00.000+0000
Updated2016-11-29T22:41:25.000+0000

Description

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.

Comments

  1. Isaac Whitfield 2016-11-22

    This was brought up on Slack and it appears to be an invalid ticket. setMessage is a function, and should therefore be invoked as toast.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 used toast.message = "Please Stand By" instead.
  2. Hans Knöchel 2016-11-23

    [~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?
  3. Lokesh Choudhary 2016-11-29

    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

JSON Source