sendPush vs. sendNotification() w/ no method specified

Is there any difference? If so, when is use of one over the other preferable? I’ve read this and tested both, but it’s not clear to me why there would be two apparently identical methods (i.e., they both send a push notification that also appears in the Notifications feed).

From the article you linked to (here’s the specific section):

The sendNotification() method allows you to send both push and/or SMS messages, in one convenient method call. It can also optionally display the message in the Notifications feed.

sendNotification() takes a message parameter, and a map of options that control how the message should be sent, if the message should be displayed in the Notifications feed, and a phone number to send an SMS to (if specified):

sendPush is just sending a push message to the phone. sendNotification has options to send an SMS, send a push message, or send both.

This isn’t correct. sendPush is also writing to the Notifications feed. I don’t think it used to do this, but it does now!

The clarification I was trying to make was between the method of delivery. SMS vs Push.

I was trying to clarify that there is:

//send a push message
sendPush(message)
//send an SMS
sendSms(phonenumber, message)
//send an SMS and push message
sendNotification(message, [method: "both", phone: phonenumber])

To your point, it’s also worth considering the options around the notification feed. The documentation clarifies this further. All the above methods will include the message in the notification feed (sendPush, sendSms, sendNotification)

If you don’t want the message showing in the notification feed, you would use:

//send a push without displaying in the notification feed
sendPushMessage(message)
//send an SMS without displaying in the notification feed
sendSmsMessage(phonenumber, message)
//send an SMS and  push message without displaying in the notification feed
sendNotification(message, [method: "both", phone: phonenumber, event: false])

Also note that the method option in sendNotification allows for phone, push, or both giving you some flexibility with your delivery options.

1 Like

You didn’t read the entire section. Under Send Push Notifications:

and under Send Both Push and SMS Notifications:

[quote]// sends a push notification, and displays it in the Notifications feed
sendNotification(“test notification - no params”)[/quote]

I’ve substituted one for the other in a smartapp and they work identically… unless there is some scenario I am unaware of where they act differently :question:

Your point about the additional capability offered by sendNotification is valid, but in the title I specifically stated “sendNotification w/ no method specified” (i.e., the second example above). IOW, I can’t find a difference between sendPush msg and sendNotification msg.They both send a push message to all mobile subscribers on the account and both append an entry in the Notifications feed.

@Jim, @unixbeast: Can you shed any light? Is there actually any difference, or is maybe one soon to be deprecated?

sendPush() delegates to sendNotification() using [method: 'push'].

And since sendNotification() defaults to 'push' method, there is no difference in that case. In general, sendNotification() is a flexible API that is used in the internal implementation by delegation, as well as available in the public API. sendPush() is more specific, but it does just delegate to sendNotification().

1 Like