Android API
I've been playing around with ways to send remote commands to my Android device and I've come up with something that resembles an API if you cobble it together with just a few steps.
The Concept
It takes two apps and a small bit of configuration.
First, send an http
request to the ntfy service. The companion app on the Android device listens for and receives updates from that service. These updates trigger an Android [Intent]().
Next, use Tasker to monitor all intents on the device and react to them if they meet certain parameters. So long as the original request contains those parameters, trigger a response with a custom action.
The Breakdown
Read up on how to create ntfy messages for yourself and subscribe to a topic.
Download Tasker* and create a new profile with the Event type, adding io.heckel.ntfy.MESSAGE_RECEIVED
as the action and leaving the rest as is. The profile will prompt you to create a task.
*Note on the download link: That link is to get the APK and install it yourself if you're savvy enough.
I am normally loathe to recommend the Google Play Store, but that is where the developer works primarily, and downloading their official version will prevent certain advanced functionality from breaking and allow you to bundle all kinds of other stuff the developer builds.
In the task, you can run any actions you want. The only thing you have to add is a filter on any parameters you included in the ntfy http
request, whose names match the resulting Tasker parameters:
%topic
%title
%message
%tags
This will prevent your task from being triggered by any ntfy message received according to the intent.
Summary
And that's it! It's an http
request to ntfy which triggers a Tasker action if the device is configured properly.
Use case ideas
- Turn all volume settings to maximum so you can ping/locate device.
- Send an SMS when your device isn't near you.
- Open a URL in the device browser for later.
- Remotely take pictures.
- Have device report back status indicators, such as battery level, current WiFi network, etc...