Implementing One-Click Find iPhone with Alfred

· 2 min read

Mac’s Find My feature is quite commonly used - selecting an Apple device to play sound while viewing the device’s approximate location and online status. However, whether it’s the web or app version, the operation experience is still cumbersome and loading is very slow.

As an Alfred efficiency fan, I spent the weekend trying to develop a workflow to solve the efficiency problem.

Implementation Foundation

Find My has both App and Web versions. The App version doesn’t provide Apple Script support, and GUI automation experience isn’t good either, so I abandoned it.

Web version iCloud Find can be analyzed through packet capture for API requests, allowing workflow implementation.

Pitfalls Encountered

  1. iCloud login will enable MFA if it’s the first time logging in on a new web client, and the requests involve many authentication parameters. Therefore, first login must be done on the web site to make iCloud trust the device, while capturing requests to obtain all authentication-related parameters.

  2. iCloud API cookies have extremely short validity periods. Authentication information refreshes periodically, so if cookies are used as Alfred parameters, values need constant updating. To avoid users manually copying information to workflow configuration each time, iCloud ID and password need to be stored for automatic login when requests expire to obtain new cookie information.

  3. A good way to persistently store cookies and other authentication information is in workflow environment variables, though file storage is also possible. I chose workflow environment variables. To permanently/dynamically write new values to the workflow, Apple Script commands need to be executed.

  4. Different devices need to display corresponding device images. Fortunately, there’s an open source project that organizes Apple device numbers/names, making image lookup convenient.

Implementation Effect

Download link: Click here

  • ⌥ ⏎ Play sound
  • ⌘ ⏎ Browse iCloud Web
  • Green and white dots represent current device status; green means online

Configuration

Due to iCloud’s high security, the workflow cannot be used immediately after installation - some parameter configuration is required.

To make iCloud trust the device, you must first log in to the web version once and obtain some parameters from any request after accessing iCloud Find My to configure in the workflow environment. Since login information has extremely short validity, iCloud account/password configuration is needed for password-free login.

Final Thoughts

After implementing the above, you can quickly trigger any Apple device - perfect!