From a4504290ff563e47d8eeb7aad99349f5fc9314c5 Mon Sep 17 00:00:00 2001 From: edlea Date: Tue, 2 May 2017 21:03:06 +0100 Subject: [PATCH 1/2] Custom subject/label for alert message --- index.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index d245adf..e096c54 100644 --- a/index.js +++ b/index.js @@ -139,14 +139,26 @@ var findmyphone = { callback(error, devices); }); }, - alertDevice: function(deviceId, callback) { - var options = { - url: findmyphone.base_path + "/fmipservice/client/web/playSound", - json: { - "subject": "Amazon Echo Find My iPhone Alert", - "device": deviceId + alertDevice: function(options, callback) { + var url = findmyphone.base_path + "/fmipservice/client/web/playSound"; + if ('object' === typeof(options) && options.hasOwnProperty('deviceID')) { + options = { + url: url, + json: { + "subject": options.subject || "Amazon Echo Find My iPhone Alert", + "device": options.deviceID + } } - }; + } + else { // backwards compatibility for deviceId string provided + options = { + url: url, + json: { + "subject": "Amazon Echo Find My iPhone Alert", + "device": options + } + }; + } findmyphone.iRequest.post(options, callback); }, getLocationOfDevice: function(device, callback) { From 0fd962e931b48599679fab24143f103b9c05d0cf Mon Sep 17 00:00:00 2001 From: edlea Date: Tue, 2 May 2017 21:06:54 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0d8bc86..19da605 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Here's a basic example using all the methods var icloud = require("find-my-iphone").findmyphone; icloud.apple_id = "steve@jobs.com"; - icloud.password = "oneMoreThing"; + icloud.password = "oneMoreThing"; icloud.getDevices(function(error, devices) { var device; @@ -54,7 +54,7 @@ Here's a basic example using all the methods console.log("Driving time: " + result.duration.text); }); - icloud.alertDevice(device.id, function(err) { + icloud.alertDevice({deviceID: device.id, subject: 'node.js demo'}, function(err) { console.log("Beep Beep!"); }); @@ -91,11 +91,7 @@ find(email,password[,label[,callback]]) * password (required): Your iCloud password * label (optional): The label of the phone you want to alert (iCloud accounts may have multiple devices). The label can be found under "All Devices" in the Find My iPhone app. If there are multiple phones with the same label, the last one matching will be alerted. You should rename devices to be unique. * callback (optional): A function to execute when the phone has been alerted - + # Tests `apple_id=someone@gmail.com apple_password=somePassword mocha test` - - - -