{"id":76925,"date":"2026-02-23T15:22:17","date_gmt":"2026-02-23T07:22:17","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76925.html"},"modified":"2026-02-23T15:22:17","modified_gmt":"2026-02-23T07:22:17","slug":"bark%e6%8e%a8%e9%80%81%e5%ae%9e%e6%88%98%ef%bc%9a5%e5%88%86%e9%92%9f%e6%90%9e%e5%ae%9a%e8%87%aa%e5%bb%ba%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f%ef%bc%88%e5%90%ab%e5%b8%b8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76925.html","title":{"rendered":"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09"},"content":{"rendered":"<h2>Bark\u63a8\u9001\u5168\u6808\u6307\u5357&#xff1a;\u4ece\u96f6\u6784\u5efa\u79c1\u6709\u5316\u6d88\u606f\u901a\u77e5\u7cfb\u7edf<\/h2>\n<p>\u5728\u4fe1\u606f\u8fc7\u8f7d\u7684\u65f6\u4ee3&#xff0c;\u5982\u4f55\u7cbe\u51c6\u83b7\u53d6\u5173\u952e\u901a\u77e5\u6210\u4e3a\u6548\u7387\u5de5\u5177\u7684\u6838\u5fc3\u547d\u9898\u3002Bark\u4f5c\u4e3aiOS\u751f\u6001\u4e2d\u6700\u8f7b\u91cf\u7ea7\u7684\u6d88\u606f\u63a8\u9001\u65b9\u6848&#xff0c;\u51ed\u501f\u5176\u5f00\u6e90\u7279\u6027\u3001APNs\u539f\u751f\u901a\u9053\u548c\u6781\u7b80API\u8bbe\u8ba1&#xff0c;\u6b63\u5728\u6210\u4e3a\u5f00\u53d1\u8005\u6784\u5efa\u79c1\u6709\u5316\u901a\u77e5\u7cfb\u7edf\u7684\u9996\u9009\u3002\u672c\u6587\u5c06\u5e26\u60a8\u6df1\u5165Bark\u6280\u672f\u6808&#xff0c;\u4ece\u670d\u52a1\u5668\u90e8\u7f72\u5230\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1&#xff0c;\u6253\u9020\u5b8c\u5168\u81ea\u4e3b\u53ef\u63a7\u7684\u6d88\u606f\u63a8\u9001\u4f53\u7cfb\u3002<\/p>\n<h3>1. \u67b6\u6784\u8bbe\u8ba1\u4e0e\u6280\u672f\u9009\u578b<\/h3>\n<p>Bark\u7684\u72ec\u7279\u4ef7\u503c\u5728\u4e8e\u5176&#034;\u8f7b\u91cf\u7ea7\u67b6\u6784&#043;\u4f01\u4e1a\u7ea7\u901a\u9053&#034;\u7684\u6df7\u5408\u8bbe\u8ba1\u3002\u4e0e\u5e38\u89c4\u63a8\u9001\u670d\u52a1\u76f8\u6bd4&#xff0c;\u5b83\u65e2\u4fdd\u7559\u4e86\u81ea\u5efa\u670d\u52a1\u7684\u7075\u6d3b\u6027&#xff0c;\u53c8\u7ee7\u627f\u4e86\u82f9\u679cAPNs\u670d\u52a1\u7684\u53ef\u9760\u6027\u3002\u5176\u6280\u672f\u67b6\u6784\u53ef\u5206\u4e3a\u4e09\u4e2a\u5173\u952e\u5c42\u7ea7&#xff1a;<\/p>\n<ul>\n<li>\u5ba2\u6237\u7aef\u5c42&#xff1a;iOS\u539f\u751f\u5e94\u7528&#xff0c;\u901a\u8fc7APNs\u6ce8\u518c\u83b7\u53d6deviceToken<\/li>\n<li>\u670d\u52a1\u5c42&#xff1a;\u81ea\u5efabark-server&#xff0c;\u5904\u7406\u6d88\u606f\u8def\u7531\u548c\u683c\u5f0f\u8f6c\u6362<\/li>\n<li>\u901a\u9053\u5c42&#xff1a;\u82f9\u679cAPNs\u5b98\u65b9\u63a8\u9001\u901a\u9053&#xff0c;\u786e\u4fdd\u6d88\u606f\u5fc5\u8fbe<\/li>\n<\/ul>\n<p>graph TD<br \/>\n    A[\u5ba2\u6237\u7aef\u8bbe\u5907] &#8211;&gt;|1. \u6ce8\u518cdeviceToken| B(bark-server)<br \/>\n    C[\u6d88\u606f\u751f\u4ea7\u8005] &#8211;&gt;|2. \u53d1\u9001\u63a8\u9001\u8bf7\u6c42| B<br \/>\n    B &#8211;&gt;|3. \u8f6c\u53d1\u5230APNs| D[\u82f9\u679c\u670d\u52a1\u5668]<br \/>\n    D &#8211;&gt;|4. \u63a8\u9001\u5230\u8bbe\u5907| A<\/p>\n<p>\u8fd9\u79cd\u67b6\u6784\u5e26\u6765\u4e24\u4e2a\u663e\u8457\u4f18\u52bf&#xff1a;<\/p>\n<li>\u4f4e\u529f\u8017&#xff1a;\u5e94\u7528\u65e0\u9700\u5e38\u9a7b\u540e\u53f0&#xff0c;\u4f9d\u8d56\u7cfb\u7edf\u7ea7\u63a8\u9001<\/li>\n<li>\u9ad8\u53ef\u9760&#xff1a;\u6d88\u606f\u901a\u8fc7\u82f9\u679c\u5168\u7403\u57fa\u7840\u8bbe\u65bd\u5206\u53d1<\/li>\n<h3>2. \u670d\u52a1\u7aef\u90e8\u7f72\u5b9e\u6218<\/h3>\n<h4>2.1 Docker\u6807\u51c6\u5316\u90e8\u7f72<\/h4>\n<p>\u63a8\u8350\u4f7f\u7528Docker Compose\u5b9e\u73b0\u4e00\u952e\u90e8\u7f72&#xff0c;\u4ee5\u4e0b\u4e3a\u751f\u4ea7\u7ea7\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<p>version: &#039;3&#039;<br \/>\nservices:<br \/>\n  bark:<br \/>\n    image: finab\/bark-server<br \/>\n    container_name: bark<br \/>\n    restart: unless-stopped<br \/>\n    ports:<br \/>\n      &#8211; &#034;8080:8080&#034;<br \/>\n    volumes:<br \/>\n      &#8211; .\/data:\/data<br \/>\n    environment:<br \/>\n      &#8211; BARK_HTTP_PORT&#061;8080<br \/>\n      &#8211; BARK_DEVICE_KEY&#061;YOUR_SECURE_KEY<br \/>\n    healthcheck:<br \/>\n      test: [&#034;CMD&#034;, &#034;curl&#034;, &#034;-f&#034;, &#034;http:\/\/localhost:8080\/ping&#034;]<br \/>\n      interval: 30s<br \/>\n      timeout: 5s<br \/>\n      retries: 3<\/p>\n<p>\u5173\u952e\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tr>\u53c2\u6570\u5fc5\u8981\u6027\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>BARK_HTTP_PORT<\/td>\n<td>\u5fc5\u9009<\/td>\n<td>\u670d\u52a1\u76d1\u542c\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>BARK_DEVICE_KEY<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u5168\u5c40\u8bbe\u5907\u5bc6\u94a5<\/td>\n<\/tr>\n<tr>\n<td>BARK_DATA_DIR<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u6570\u636e\u5b58\u50a8\u8def\u5f84<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.2 \u6027\u80fd\u8c03\u4f18\u6307\u5357<\/h4>\n<p>\u5f53QPS\u8d85\u8fc7100\u65f6&#xff0c;\u9700\u8981\u8c03\u6574\u4ee5\u4e0b\u53c2\u6570&#xff1a;<\/p>\n<p>docker run \\\\<br \/>\n  -e BARK_MAX_APNS_CLIENTS&#061;20 \\\\<br \/>\n  -e BARK_WORKER_POOL&#061;50 \\\\<br \/>\n  finab\/bark-server<\/p>\n<p>\u5178\u578b\u6027\u80fd\u6307\u6807&#xff1a;<\/p>\n<ul>\n<li>\u5355\u68382GB\u5185\u5b58&#xff1a;\u652f\u6301\u7ea6300 QPS<\/li>\n<li>\u589e\u52a0BARK_WORKER_POOL\u53ef\u63d0\u5347\u5e76\u53d1\u5904\u7406\u80fd\u529b<\/li>\n<li>\u4f7f\u7528Redis\u7f13\u5b58\u8bbe\u5907\u4fe1\u606f\u53ef\u964d\u4f4e\u6570\u636e\u5e93\u538b\u529b<\/li>\n<\/ul>\n<h3>3. \u5ba2\u6237\u7aef\u96c6\u6210\u65b9\u6848<\/h3>\n<h4>3.1 \u8bbe\u5907\u6ce8\u518c\u6d41\u7a0b<\/h4>\n<p>\u5728iOS\u5ba2\u6237\u7aef\u83b7\u53d6\u552f\u4e00\u6807\u8bc6\u7684\u5b8c\u6574\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>import UserNotifications<\/p>\n<p>func registerForNotifications() {<br \/>\n    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { granted, _ in<br \/>\n        guard granted else { return }<br \/>\n        DispatchQueue.main.async {<br \/>\n            UIApplication.shared.registerForRemoteNotifications()<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>func application(_ application: UIApplication,<br \/>\n                 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {<br \/>\n    let token &#061; deviceToken.map { String(format: &#034;%02.2hhx&#034;, $0) }.joined()<br \/>\n    let url &#061; URL(string: &#034;https:\/\/your-server\/register?device_token&#061;\\\\(token)&#034;)!<br \/>\n    URLSession.shared.dataTask(with: url).resume()<br \/>\n}<\/p>\n<h4>3.2 \u6d88\u606f\u63a8\u9001API\u8be6\u89e3<\/h4>\n<p>Bark\u652f\u6301\u4e24\u79cd\u6d88\u606f\u683c\u5f0f&#xff1a;<\/p>\n<p>URL\u53c2\u6570\u5f0f&#xff1a;<\/p>\n<p>https:\/\/api.example.com\/push\/&lt;key&gt;\/&lt;title&gt;\/&lt;body&gt;?group&#061;alert&#038;sound&#061;bell<\/p>\n<p>JSON Body\u5f0f&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;title&#034;: &#034;\u670d\u52a1\u5f02\u5e38&#034;,<br \/>\n  &#034;body&#034;: &#034;API\u54cd\u5e94\u8d85\u65f6\u9608\u503c\u7a81\u7834&#034;,<br \/>\n  &#034;badge&#034;: 1,<br \/>\n  &#034;sound&#034;: &#034;alarm.caf&#034;,<br \/>\n  &#034;icon&#034;: &#034;https:\/\/example.com\/alert.png&#034;,<br \/>\n  &#034;url&#034;: &#034;https:\/\/status.example.com&#034;,<br \/>\n  &#034;level&#034;: &#034;timeSensitive&#034;<br \/>\n}<\/p>\n<p>\u9ad8\u7ea7\u53c2\u6570\u5bf9\u7167\u8868&#xff1a;<\/p>\n<table>\n<tr>\u53c2\u6570iOS\u7248\u672c\u8981\u6c42\u6548\u679c<\/tr>\n<tbody>\n<tr>\n<td>level&#061;timeSensitive<\/td>\n<td>iOS 15&#043;<\/td>\n<td>\u7a81\u7834\u52ff\u6270\u6a21\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>interruptionLevel&#061;critical<\/td>\n<td>iOS 15&#043;<\/td>\n<td>\u6301\u7eed\u54cd\u94c3\u63d0\u9192<\/td>\n<\/tr>\n<tr>\n<td>sound&#061;<\/td>\n<td>iOS 10&#043;<\/td>\n<td>\u81ea\u5b9a\u4e49\u901a\u77e5\u97f3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>4. \u5185\u7f51\u7a7f\u900f\u4e0e\u5b89\u5168\u52a0\u56fa<\/h3>\n<h4>4.1 \u7a7f\u900f\u65b9\u6848\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u65b9\u6848\u514d\u8d39\u989d\u5ea6\u5e26\u5bbd\u9650\u5236\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>ngrok<\/td>\n<td>40\u8fde\u63a5\/\u5206\u949f<\/td>\n<td>1Mbps<\/td>\n<td>\u5f00\u53d1\u6d4b\u8bd5<\/td>\n<\/tr>\n<tr>\n<td>Cloudflare Tunnel<\/td>\n<td>\u65e0\u9650<\/td>\n<td>100Mbps<\/td>\n<td>\u751f\u4ea7\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>frp<\/td>\n<td>\u81ea\u5efa<\/td>\n<td>\u53d6\u51b3\u4e8e\u670d\u52a1\u5668<\/td>\n<td>\u4f01\u4e1a\u5185\u7f51<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a8\u8350Cloudflare Tunnel\u914d\u7f6e\u547d\u4ee4&#xff1a;<\/p>\n<p>cloudflared tunnel create bark-tunnel<br \/>\ncloudflared tunnel route dns bark-tunnel push.yourdomain.com<br \/>\ncloudflared tunnel run &#8211;url http:\/\/localhost:8080 bark-tunnel<\/p>\n<h4>4.2 \u5b89\u5168\u9632\u62a4\u7b56\u7565<\/h4>\n<li>\n<p>HTTPS\u5f3a\u5236&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name bark.example.com;<br \/>\n    return 301 https:\/\/$host$request_uri;<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u57fa\u7840\u8ba4\u8bc1&#xff1a;<\/p>\n<p># \u751f\u6210\u5bc6\u7801\u6587\u4ef6<br \/>\necho -n &#039;admin:&#039; &gt;&gt; \/etc\/nginx\/.htpasswd<br \/>\nopenssl passwd -apr1 &gt;&gt; \/etc\/nginx\/.htpasswd<\/p>\n<\/li>\n<li>\n<p>\u8bf7\u6c42\u9650\u6d41&#xff1a;<\/p>\n<p>limit_req_zone $binary_remote_addr zone&#061;bark:10m rate&#061;10r\/s;<\/p>\n<p>location \/push {<br \/>\n    limit_req zone&#061;bark burst&#061;20;<br \/>\n    proxy_pass http:\/\/bark-server;<br \/>\n}<\/p>\n<\/li>\n<h3>5. \u4f01\u4e1a\u7ea7\u529f\u80fd\u6269\u5c55<\/h3>\n<h4>5.1 \u6d88\u606f\u52a0\u5bc6\u65b9\u6848<\/h4>\n<p>\u7aef\u5230\u7aef\u52a0\u5bc6\u5b9e\u73b0\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u5ba2\u6237\u7aef\u751f\u6210AES\u5bc6\u94a5\u5bf9<\/li>\n<li>\u670d\u52a1\u7aef\u5b58\u50a8\u516c\u94a5\u6307\u7eb9<\/li>\n<li>\u63a8\u9001\u65f6\u8fdb\u884cpayload\u52a0\u5bc6<\/li>\n<p>\u52a0\u5bc6\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p>from Crypto.Cipher import AES<br \/>\nfrom Crypto.Util.Padding import pad<br \/>\nimport base64<\/p>\n<p>def encrypt_message(key: str, message: str) -&gt; str:<br \/>\n    iv &#061; b&#039;0123456789ABCDEF&#039;<br \/>\n    cipher &#061; AES.new(key.encode(), AES.MODE_CBC, iv)<br \/>\n    encrypted &#061; cipher.encrypt(pad(message.encode(), AES.block_size))<br \/>\n    return base64.b64encode(encrypted).decode()<\/p>\n<h4>5.2 \u76d1\u63a7\u96c6\u6210\u65b9\u6848<\/h4>\n<p>Prometheus\u76d1\u63a7\u6307\u6807\u914d\u7f6e&#xff1a;<\/p>\n<p>scrape_configs:<br \/>\n  &#8211; job_name: &#039;bark&#039;<br \/>\n    metrics_path: &#039;\/metrics&#039;<br \/>\n    static_configs:<br \/>\n      &#8211; targets: [&#039;bark-server:8080&#039;]<\/p>\n<p>\u5173\u952e\u76d1\u63a7\u6307\u6807&#xff1a;<\/p>\n<ul>\n<li>bark_push_requests_total&#xff1a;\u63a8\u9001\u8bf7\u6c42\u8ba1\u6570<\/li>\n<li>bark_apns_errors&#xff1a;APNs\u53d1\u9001\u5931\u8d25\u6570<\/li>\n<li>barn_queue_length&#xff1a;\u5f85\u5904\u7406\u6d88\u606f\u961f\u5217<\/li>\n<\/ul>\n<h3>6. \u6545\u969c\u6392\u67e5\u624b\u518c<\/h3>\n<h4>6.1 \u5e38\u89c1\u9519\u8bef\u4ee3\u7801<\/h4>\n<table>\n<tr>\u72b6\u6001\u7801\u542b\u4e49\u89e3\u51b3\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>400<\/td>\n<td>\u65e0\u6548\u8bbe\u5907\u5bc6\u94a5<\/td>\n<td>\u68c0\u67e5\u5ba2\u6237\u7aef\u6ce8\u518c\u6d41\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>502<\/td>\n<td>APNs\u8fde\u63a5\u5931\u8d25<\/td>\n<td>\u9a8c\u8bc1\u670d\u52a1\u5668\u7f51\u7edc\u8fde\u901a\u6027<\/td>\n<\/tr>\n<tr>\n<td>429<\/td>\n<td>\u8bf7\u6c42\u9891\u7387\u9650\u5236<\/td>\n<td>\u8c03\u6574\u5ba2\u6237\u7aef\u91cd\u8bd5\u7b56\u7565<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.2 \u65e5\u5fd7\u5206\u6790\u6280\u5de7<\/h4>\n<p>\u5178\u578b\u9519\u8bef\u65e5\u5fd7\u793a\u4f8b&#xff1a;<\/p>\n<p>2023-03-01 12:00:00 ERROR APNs\u63a8\u9001\u5931\u8d25<br \/>\ndevice_token&#061;invalid_token<br \/>\nerror&#061;BadDeviceToken<\/p>\n<p>\u5206\u6790\u6b65\u9aa4&#xff1a;<\/p>\n<li>\u68c0\u67e5\u8bbe\u5907\u4ee4\u724c\u662f\u5426\u8fc7\u671f<\/li>\n<li>\u9a8c\u8bc1APNs\u8bc1\u4e66\u6709\u6548\u6027<\/li>\n<li>\u786e\u8ba4bundle id\u5339\u914d<\/li>\n<h3>7. \u751f\u6001\u96c6\u6210\u5b9e\u8df5<\/h3>\n<h4>7.1 CI\/CD\u901a\u77e5\u96c6\u6210<\/h4>\n<p>GitHub Actions\u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<p>&#8211; name: Notify build status<br \/>\n  if: always()<br \/>\n  run: |<br \/>\n    curl -X POST &#034;https:\/\/api.example.com\/push\/${{ secrets.BARK_KEY }}&#034; \\\\<br \/>\n      -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n      -d &#039;{<br \/>\n        &#034;title&#034;: &#034;Build ${{ job.status }}&#034;,<br \/>\n        &#034;body&#034;: &#034;${{ github.workflow }} #${{ github.run_number }}&#034;,<br \/>\n        &#034;icon&#034;: &#034;https:\/\/github.com\/identicons\/${{ github.actor }}.png&#034;<br \/>\n      }&#039;<\/p>\n<h4>7.2 \u7269\u8054\u7f51\u573a\u666f\u5e94\u7528<\/h4>\n<p>Home Assistant\u81ea\u52a8\u5316\u914d\u7f6e&#xff1a;<\/p>\n<p>automation:<br \/>\n  &#8211; alias: Alert when door opened<br \/>\n    trigger:<br \/>\n      platform: state<br \/>\n      entity_id: binary_sensor.front_door<br \/>\n      to: &#034;on&#034;<br \/>\n    action:<br \/>\n      service: rest_command.bark_push<br \/>\n      data:<br \/>\n        title: &#034;\u5b89\u5168\u8b66\u62a5&#034;<br \/>\n        body: &#034;\u524d\u95e8\u88ab\u6253\u5f00&#034;<br \/>\n        sound: &#034;alert&#034;<\/p>\n<p>rest_command:<br \/>\n  bark_push:<br \/>\n    url: &#034;https:\/\/api.example.com\/push\/{{ key }}&#034;<br \/>\n    method: POST<br \/>\n    content_type: &#034;application\/json&#034;<br \/>\n    payload: &#039;{&#034;title&#034;:&#034;{{ title }}&#034;,&#034;body&#034;:&#034;{{ body }}&#034;,&#034;sound&#034;:&#034;{{ sound }}&#034;}&#039;<\/p>\n<h3>8. \u6027\u80fd\u4f18\u5316\u8fdb\u9636<\/h3>\n<h4>8.1 \u96c6\u7fa4\u5316\u90e8\u7f72<\/h4>\n<p>\u4f7f\u7528Nginx\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861&#xff1a;<\/p>\n<p>upstream bark_cluster {<br \/>\n    server bark1:8080;<br \/>\n    server bark2:8080;<br \/>\n    server bark3:8080;<br \/>\n    keepalive 32;<br \/>\n}<\/p>\n<p>server {<br \/>\n    location \/ {<br \/>\n        proxy_pass http:\/\/bark_cluster;<br \/>\n        proxy_http_version 1.1;<br \/>\n        proxy_set_header Connection &#034;&#034;;<br \/>\n    }<br \/>\n}<\/p>\n<h4>8.2 \u6301\u4e45\u5316\u914d\u7f6e<\/h4>\n<p>\u6d88\u606f\u5b58\u50a8\u5230PostgreSQL&#xff1a;<\/p>\n<p>docker run -e BARK_DB_DSN&#061;&#034;postgres:\/\/user:pass&#064;db:5432\/bark&#034; finab\/bark-server<\/p>\n<p>\u6570\u636e\u5e93\u8868\u7ed3\u6784\u5efa\u8bae&#xff1a;<\/p>\n<p>CREATE TABLE devices (<br \/>\n    id SERIAL PRIMARY KEY,<br \/>\n    key VARCHAR(64) UNIQUE,<br \/>\n    token TEXT NOT NULL,<br \/>\n    created_at TIMESTAMPTZ DEFAULT NOW()<br \/>\n);<\/p>\n<p>CREATE TABLE messages (<br \/>\n    id BIGSERIAL PRIMARY KEY,<br \/>\n    device_id INTEGER REFERENCES devices(id),<br \/>\n    content JSONB NOT NULL,<br \/>\n    status SMALLINT DEFAULT 0,<br \/>\n    created_at TIMESTAMPTZ DEFAULT NOW()<br \/>\n);<\/p>\n<h3>9. \u66ff\u4ee3\u65b9\u6848\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u7279\u6027BarkPushoverTelegram Bot<\/tr>\n<tbody>\n<tr>\n<td>\u81ea\u5efa\u6210\u672c<\/td>\n<td>\u514d\u8d39<\/td>\n<td>$5\/\u7528\u6237<\/td>\n<td>\u514d\u8d39<\/td>\n<\/tr>\n<tr>\n<td>\u63a8\u9001\u5ef6\u8fdf<\/td>\n<td>&lt;1s<\/td>\n<td>&lt;5s<\/td>\n<td>&lt;3s<\/td>\n<\/tr>\n<tr>\n<td>\u5386\u53f2\u8bb0\u5f55<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u4ed8\u8d39<\/td>\n<td>\u6c38\u4e45<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u5e73\u53f0<\/td>\n<td>\u9700\u9002\u914d<\/td>\n<td>\u539f\u751f\u652f\u6301<\/td>\n<td>\u539f\u751f\u652f\u6301<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>10. \u524d\u6cbf\u53d1\u5c55\u65b9\u5411<\/h3>\n<li>M1\/M2\u82af\u7247\u539f\u751f\u652f\u6301&#xff1a;\u63d0\u5347ARM\u67b6\u6784\u4e0b\u7684\u6027\u80fd\u8868\u73b0<\/li>\n<li>Swift\u91cd\u5199\u670d\u52a1\u7aef&#xff1a;\u964d\u4f4e\u5185\u5b58\u5360\u752830%\u4ee5\u4e0a<\/li>\n<li>WebSocket\u957f\u8fde\u63a5&#xff1a;\u5b9e\u73b0\u53cc\u5411\u901a\u4fe1\u80fd\u529b<\/li>\n<li>Edge Functions\u96c6\u6210&#xff1a;\u652f\u6301Cloudflare Workers\u7b49\u8fb9\u7f18\u8ba1\u7b97<\/li>\n<p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528Bark\u4f5c\u4e3a\u76d1\u63a7\u544a\u8b66\u901a\u9053\u5df2\u6709\u4e24\u5e74\u65f6\u95f4&#xff0c;\u6700\u6df1\u523b\u7684\u4f53\u4f1a\u662f\u5176\u96be\u4ee5\u7f6e\u4fe1\u7684\u7a33\u5b9a\u6027\u2014\u2014\u5373\u4f7f\u5728\u8de8\u6d32\u9645\u7684\u7f51\u7edc\u73af\u5883\u4e2d&#xff0c;\u6d88\u606f\u5ef6\u8fdf\u4ece\u672a\u8d85\u8fc72\u79d2\u3002\u8fd9\u79cd\u53ef\u9760\u6027\u4f7f\u5f97\u6211\u4eec\u9010\u6b65\u5c06\u5173\u952e\u4e1a\u52a1\u901a\u77e5\u90fd\u8fc1\u79fb\u5230\u4e86\u8fd9\u4e2a\u81ea\u5efa\u4f53\u7cfb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bark\u63a8\u9001\u5168\u6808\u6307\u5357&#xff1a;\u4ece\u96f6\u6784\u5efa\u79c1\u6709\u5316\u6d88\u606f\u901a\u77e5\u7cfb\u7edf<br \/>\n\u5728\u4fe1\u606f\u8fc7\u8f7d\u7684\u65f6\u4ee3&#xff0c;\u5982\u4f55\u7cbe\u51c6\u83b7\u53d6\u5173\u952e\u901a\u77e5\u6210\u4e3a\u6548\u7387\u5de5\u5177\u7684\u6838\u5fc3\u547d\u9898\u3002Bark\u4f5c\u4e3aiOS\u751f\u6001\u4e2d\u6700\u8f7b\u91cf\u7ea7\u7684\u6d88\u606f\u63a8\u9001\u65b9\u6848&#xff0c;\u51ed\u501f\u5176\u5f00\u6e90\u7279\u6027\u3001APNs\u539f\u751f\u901a\u9053\u548c\u6781\u7b80API\u8bbe\u8ba1&#xff0c;\u6b63\u5728\u6210\u4e3a\u5f00\u53d1\u8005\u6784\u5efa\u79c1\u6709\u5316\u901a\u77e5\u7cfb\u7edf\u7684\u9996\u9009\u3002\u672c\u6587\u5c06\u5e26\u60a8\u6df1\u5165Bark\u6280\u672f\u6808&#xff0c;\u4ece\u670d\u52a1\u5668\u90e8\u7f72\u5230\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1&#xff0c;\u6253\u9020\u5b8c\u5168\u81ea\u4e3b\u53ef\u63a7\u7684\u6d88\u606f\u63a8\u9001\u4f53\u7cfb\u3002<br \/>\n1. \u67b6\u6784\u8bbe\u8ba1\u4e0e\u6280\u672f\u9009\u578b<br \/>\nBark\u7684\u72ec\u7279\u4ef7\u503c\u5728\u4e8e\u5176\\&#8221;\u8f7b<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8366,8368,8367,3000],"topic":[],"class_list":["post-76925","post","type-post","status-publish","format-standard","hentry","category-server","tag-bark","tag-ios","tag-8367","tag-3000"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76925.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Bark\u63a8\u9001\u5168\u6808\u6307\u5357&#xff1a;\u4ece\u96f6\u6784\u5efa\u79c1\u6709\u5316\u6d88\u606f\u901a\u77e5\u7cfb\u7edf \u5728\u4fe1\u606f\u8fc7\u8f7d\u7684\u65f6\u4ee3&#xff0c;\u5982\u4f55\u7cbe\u51c6\u83b7\u53d6\u5173\u952e\u901a\u77e5\u6210\u4e3a\u6548\u7387\u5de5\u5177\u7684\u6838\u5fc3\u547d\u9898\u3002Bark\u4f5c\u4e3aiOS\u751f\u6001\u4e2d\u6700\u8f7b\u91cf\u7ea7\u7684\u6d88\u606f\u63a8\u9001\u65b9\u6848&#xff0c;\u51ed\u501f\u5176\u5f00\u6e90\u7279\u6027\u3001APNs\u539f\u751f\u901a\u9053\u548c\u6781\u7b80API\u8bbe\u8ba1&#xff0c;\u6b63\u5728\u6210\u4e3a\u5f00\u53d1\u8005\u6784\u5efa\u79c1\u6709\u5316\u901a\u77e5\u7cfb\u7edf\u7684\u9996\u9009\u3002\u672c\u6587\u5c06\u5e26\u60a8\u6df1\u5165Bark\u6280\u672f\u6808&#xff0c;\u4ece\u670d\u52a1\u5668\u90e8\u7f72\u5230\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1&#xff0c;\u6253\u9020\u5b8c\u5168\u81ea\u4e3b\u53ef\u63a7\u7684\u6d88\u606f\u63a8\u9001\u4f53\u7cfb\u3002 1. \u67b6\u6784\u8bbe\u8ba1\u4e0e\u6280\u672f\u9009\u578b Bark\u7684\u72ec\u7279\u4ef7\u503c\u5728\u4e8e\u5176&quot;\u8f7b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76925.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-23T07:22:17+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76925.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76925.html\",\"name\":\"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-23T07:22:17+00:00\",\"dateModified\":\"2026-02-23T07:22:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76925.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76925.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76925.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76925.html","og_locale":"zh_CN","og_type":"article","og_title":"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Bark\u63a8\u9001\u5168\u6808\u6307\u5357&#xff1a;\u4ece\u96f6\u6784\u5efa\u79c1\u6709\u5316\u6d88\u606f\u901a\u77e5\u7cfb\u7edf \u5728\u4fe1\u606f\u8fc7\u8f7d\u7684\u65f6\u4ee3&#xff0c;\u5982\u4f55\u7cbe\u51c6\u83b7\u53d6\u5173\u952e\u901a\u77e5\u6210\u4e3a\u6548\u7387\u5de5\u5177\u7684\u6838\u5fc3\u547d\u9898\u3002Bark\u4f5c\u4e3aiOS\u751f\u6001\u4e2d\u6700\u8f7b\u91cf\u7ea7\u7684\u6d88\u606f\u63a8\u9001\u65b9\u6848&#xff0c;\u51ed\u501f\u5176\u5f00\u6e90\u7279\u6027\u3001APNs\u539f\u751f\u901a\u9053\u548c\u6781\u7b80API\u8bbe\u8ba1&#xff0c;\u6b63\u5728\u6210\u4e3a\u5f00\u53d1\u8005\u6784\u5efa\u79c1\u6709\u5316\u901a\u77e5\u7cfb\u7edf\u7684\u9996\u9009\u3002\u672c\u6587\u5c06\u5e26\u60a8\u6df1\u5165Bark\u6280\u672f\u6808&#xff0c;\u4ece\u670d\u52a1\u5668\u90e8\u7f72\u5230\u9ad8\u7ea7\u529f\u80fd\u5f00\u53d1&#xff0c;\u6253\u9020\u5b8c\u5168\u81ea\u4e3b\u53ef\u63a7\u7684\u6d88\u606f\u63a8\u9001\u4f53\u7cfb\u3002 1. \u67b6\u6784\u8bbe\u8ba1\u4e0e\u6280\u672f\u9009\u578b Bark\u7684\u72ec\u7279\u4ef7\u503c\u5728\u4e8e\u5176\"\u8f7b","og_url":"https:\/\/www.wsisp.com\/helps\/76925.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-23T07:22:17+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76925.html","url":"https:\/\/www.wsisp.com\/helps\/76925.html","name":"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-23T07:22:17+00:00","dateModified":"2026-02-23T07:22:17+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76925.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76925.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76925.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Bark\u63a8\u9001\u5b9e\u6218\uff1a5\u5206\u949f\u641e\u5b9a\u81ea\u5efa\u670d\u52a1\u5668+\u5185\u7f51\u7a7f\u900f\uff08\u542b\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76925"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76925\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76925"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}