diff --git a/README.md b/README.md index 987ee81..2ff4260 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or When using Pushover, this option allows you to specify a single device name to send notifications to; if blank or unset, notifications will be sent to all devices. - This option must be set when using PushBullet. + This option must be set when using PushBullet. This module supports both `device_id` (older, numeric id) and the `device_iden` (newer, alphanumeric id) used by PushBullet. You can find your `device_iden` by navigating to a device page and noting the last part of the URL. ### Notifications diff --git a/push.cpp b/push.cpp index 582fb2e..6e0f465 100644 --- a/push.cpp +++ b/push.cpp @@ -196,6 +196,18 @@ class CPushMod : public CModule return result; } + /** + * Verifies whether a given string contains only numbers. + * + * @param content String to verify + */ + bool is_number(const CString& content) + { + CString::const_iterator it = content.begin(); + while(it != content.end() && std::isdigit(*it)) ++it; + return !content.empty() && it == content.end(); + } + /** * Send a message to the currently-configured push service. * Requires (and assumes) that the user has already configured their @@ -267,7 +279,14 @@ class CPushMod : public CModule service_auth = options["secret"] + CString(":"); service_auth.Base64Encode(); - params["device_id"] = options["target"]; + // Pushbullet uses numeric device_id but they + // are transitioning to an alphanumeric device_iden + if (is_number(options["target"])) + { + params["device_id"] = options["target"]; + } else { + params["device_iden"] = options["target"]; + } params["type"] = "note"; params["title"] = message_title; params["body"] = message_content;