javascript - What is a more elegant way to overcome Error: Expecting object specifier. Argument has no object specifier when sending an SMS via Messages via JXA -
this fails work
(application("messages")) { send(text, {to: services["sms"].buddies[phone]}) }
with error: expecting object specifier. argument has no object specifier.
text valid , not null. phone valid , not null. if hard code values works. decided try 'dynamic' hard coding worked.
command = 'with (application("messages")) { send("' + text + '", {to: services["sms"].buddies["' + phone + '"]}) } ;' ; eval(command) ;
is there more elegant way of overcoming this? why eval work code variables not?
breaking code out smaller pieces helps me.
var text="foo" var phone="+14159999999" var messages = application('messages') var service = messages.services[0] var recipient = service.buddies.byname(phone, { of: service }) messages.send(text , { to: recipient })
Comments
Post a Comment