bark-server
Bark is an iOS App which allows you to push customed notifications to your iPhone.
bark-server Installation
docker-copose.yaml
version: '3.8'
services:
bark-server:
image: finab/bark-server
container_name: bark-server
restart: always
volumes:
- ./data:/data
ports:
- "8080:8080"
Nginx Proxy
# generated 2020-03-26, Mozilla Guideline v5.4, nginx 1.17.7, OpenSSL 1.1.1d, modern configuration
# https://ssl-config.mozilla.org/#server=nginx&version=1.17.7&config=modern&openssl=1.1.1d&guideline=5.4
server {
listen 80;
listen [::]:80;
# Replace bark.app.dev with your real domain name.
server_name bark.app.dev;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
# Replace bark.app.dev with your real domain name.
server_name bark.app.dev;
ssl_certificate /path/to/signed_cert_plus_intermediates;
ssl_certificate_key /path/to/private_key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
# modern configuration
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
add_header Strict-Transport-Security "max-age=63072000" always;
# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;
# verify chain of trust of OCSP response using Root CA and Intermediate certs
ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;
# replace with the IP address of your resolver
#resolver 127.0.0.1;
location / {
log_not_found on;
# Replace http://192.168.1.123:8080 with the listening address of the bark server.
proxy_pass http://192.168.1.123:8080;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}
API V2
Push
Field | Type | Description |
---|---|---|
title | string | Notification title (font size would be larger than the body) |
body | string | Notification content |
category | string | Reserved field, no use yet |
device_key | string | The key for each device |
level (optional) | string | 'active' , 'timeSensitive' , or 'passive' |
badge (optional) | integer | The number displayed next to App icon (Apple Developer) |
automaticallyCopy (optional) | string | Must be 1 |
copy (optional) | string | The value to be copied |
sound (optional) | string | Value from here |
icon (optional) | string | An url to the icon, available only on iOS 15 or later |
group (optional) | string | The group of the notification |
isArchive (optional) | string | Value must be 1 . Whether or not should be archived by the app |
url (optional) | string | Url that will jump when click notification |
curl
curl -X "POST" "http://127.0.0.1:8080/push" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"body": "Test Bark Server",
"device_key": "ynJ5Ft4atkMkWeo2PAvFhF",
"title": "bleem",
"badge": 1,
"category": "myNotificationCategory",
"sound": "minuet.caf",
"icon": "https://day.app/assets/images/avatar.jpg",
"group": "test",
"url": "https://mritd.com"
}'
java
import java.io.IOException;
import org.apache.http.client.fluent.*;
import org.apache.http.entity.ContentType;
public class SendRequest
{
public static void main(String[] args) {
sendRequest();
}
private static void sendRequest() {
// push (POST )
try {
// Create request
Content content = Request.Post("http://127.0.0.1:8080/push")
// Add headers
.addHeader("Content-Type", "application/json; charset=utf-8")
// Add body
.bodyString("{\"body\": \"Test Bark Server\",\"device_key\": \"nysrshcqielvoxsa\",\"title\": \"bleem\",\"url\": \"https://mritd.com\", \"group\": \"test\",\"category\": \"myNotificationCategory\",\"sound\": \"minuet.caf\"}", ContentType.APPLICATION_JSON)
// Fetch request and return content
.execute().returnContent();
// Print content
System.out.println(content);
}
catch (IOException e) { System.out.println(e); }
}
}
php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'http://127.0.0.1:8080/push',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"body": "Test Bark Server",
"device_key": "ynJ5Ft4atkMkWeo2PAvFhF",
"title": "bleem",
"badge": 1,
"category": "myNotificationCategory",
"sound": "minuet.caf",
"icon": "https://day.app/assets/images/avatar.jpg",
"group": "test",
"url": "https://mritd.com"
}',
CURLOPT_HTTPHEADER => [
'Content-Type: application/json; charset=utf-8',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Misc
Ping
curl "http://127.0.0.1:8080/ping"
Healthz
curl "http://127.0.0.1:8080/healthz"
Info
curl "http://127.0.0.1:8080/info"
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。