blinksh / blink

Blink Mobile Shell for iOS (Mosh based)
https://blink.sh
GNU General Public License v3.0
6.13k stars 570 forks source link

Push Notifications from Server #393

Open willhbr opened 6 years ago

willhbr commented 6 years ago

A useful feature would be to allow servers to send push notifications back to your device through a command installed on the server. The main use case I am imagining is:

  1. SSH/Mosh to server, do some work
  2. Start long-running build & test
  3. Pipe a result message (exit status or something) of the tests into a shell command
  4. Receive a notification on iPad (even better, both iPad and iPhone) with the result
  5. Reconnect to server and push work/ look at results

Currently I use a janky Slack integration to do this (basically make spec; echo "Finished: $?" | slack), but seeing as Blink is able to send notifications it would be great to have this integrated into one place. Tapping the notification could reconnect back to the server, optionally attaching to the correct tmux/ screen session as well to make it even more seamless.

The script should be able to run on Linux and macOS systems, ideally installable via apt/ brew or some mechanism in Blink. It shouldn't require an active Mosh/SSH connection or for Blink to be open.

I don't know anything about Apple's push notification API and whether this is possible without Blink hosting a proxy to push out the notifications.

carloscabanero commented 6 years ago

Great idea! I remember yieldthought.com used to do something like that when he ran his iPad experiment. It would be interesting if it could be connected to Mosh too.

willhbr commented 5 years ago

Does your comment on this issue indicate any work in this direction? 😀

eddieroger commented 5 years ago

This is a pretty neat idea, and I’m interested in lending a hand here since I’ve got some experience with APNS.

I think the trickiest part of this would be that APNS requires a third-party server to send the messages to Apple. So whatever package that gets installed on the remote machines would need to make an API call to this server, which then talks to Apple, who then relay the message back to the app. None of that would be too tricky, but requires some resources in the form of a server to run this simple API. It also requires the version in the App Store to be registered for Push (also not that tricky).

I think it’d be a fun exercize to put together a proof, and am willing and excited to do that. Being only a user and not a contributor of Blink, I’m not sure the best way to show that back, but I’m certainly game to try it.

willhbr commented 5 years ago

Before you get too into this, I'd check with @carloscabanero if he is willing to fund the ongoing server costs of running something like this - it will probably be fairly easy on resources, but an ongoing cost none the less. Having an idea of the potential traffic volume would be useful as well.

Since the proxy will be run by the folks at Blink, it'd be good to use some technologies that they're familiar with, can setup a deployment for, and continue to maintain. (I'd probably opt for Elixir in this instance, but the main concern is deployment by Blink). Also, you'd have to consider what to use when implementing the client that runs on the users server to send the request - Go is probably a popular choice because you can compile to pretty much every architecture with almost no effort. Since this has potential to be abused, it would be good to think of per-user (or per-device) throttling/blacklisting from the start.

I'd be happy to help where I can, it'd be really cool to have this in Blink!