### Start gorush service via /etc/init.d/gorush Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/contrib/init/debian/README.md Start the gorush service using the installed init script. ```sh /etc/init.d/gorush start ``` -------------------------------- ### Install dependencies with yarn Source: https://github.com/easychen/pushdeer/blob/main/quickapp/README.md Installs project dependencies for the QuickApp source. Run from the repository root after cloning the source. ```bash cd quickapp && yarn ``` -------------------------------- ### Start PushDeer with MQTT via docker-compose Source: https://github.com/easychen/pushdeer/blob/main/iot/README.md Starts the self-hosted PushDeer stack with the MQTT service enabled. Use this after editing the docker-compose file as shown in the previous example. ```bash docker-compose -f docker-compose.self-hosted.yml up --build -d ``` -------------------------------- ### Install gorush binary to /usr/bin and set executable permission Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/contrib/init/debian/README.md Place the gorush binary in /usr/bin and make it executable before installing the init script. ```sh cp gorush /usr/bin/ chmod +x /usr/bin/gorush ``` -------------------------------- ### Install dependencies and grpc-tools Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/rpc/example/node/README.md Run these commands to install project dependencies and the grpc-tools package globally. Requires Node 12.x or greater. ```sh npm install npm install -g grpc-tools ``` -------------------------------- ### Install Gorush via go get Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Downloads and installs Gorush using Go's package manager. ```sh go get -u -v github.com/appleboy/gorush ``` -------------------------------- ### GET /sys/stats response example Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example JSON response from GET /sys/stats, showing response time, status code counts, and process uptime. ```json { "pid": 80332, "uptime": "1m42.428010614s", "uptime_sec": 102.428010614, "time": "2016-06-26 12:27:11.675973571 +0800 CST", "unixtime": 1466915231, "status_code_count": { }, "total_status_code_count": { "200": 5 }, "count": 0, "total_count": 5, "total_response_time": "10.422441ms", "total_response_time_sec": 0.010422441000000001, "average_response_time": "2.084488ms", "average_response_time_sec": 0.0020844880000000002 } ``` -------------------------------- ### Create /etc/gorush and copy sample config.yml Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/contrib/init/debian/README.md Create the gorush configuration directory and copy a sample config file before starting the service. ```sh mkdir -p /etc/gorush cp config/testdata/config.yml /etc/gorush/ ``` -------------------------------- ### GET /api/stat/go response example Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example JSON response from GET /api/stat/go, showing Go runtime statistics such as memory, garbage collection, and goroutine counts. The endpoint returns HTTP 200. ```json { "time": 1460686815848046600, "go_version": "go1.6.1", "go_os": "darwin", "go_arch": "amd64", "cpu_num": 4, "goroutine_num": 15, "gomaxprocs": 4, "cgo_call_num": 1, "memory_alloc": 7455192, "memory_total_alloc": 8935464, "memory_sys": 12560632, "memory_lookups": 17, "memory_mallocs": 31426, "memory_frees": 11772, "memory_stack": 524288, "heap_alloc": 7455192, "heap_sys": 8912896, "heap_idle": 909312, "heap_inuse": 8003584, "heap_released": 0, "heap_objects": 19654, "gc_next": 9754725, "gc_last": 1460686815762559700, "gc_num": 2, "gc_per_second": 0, "gc_pause_per_second": 0, "gc_pause": [ 0.326576, 0.227096 ] } ``` -------------------------------- ### Install PromiseKit CorePromise without extensions Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/PromiseKit/README.md Installs PromiseKit without any extensions. Carthage installations come with no extensions by default. ```ruby pod "PromiseKit/CorePromise", "~> 6.8" ``` -------------------------------- ### Initialize git repository Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/Moya/Readme.md Run this command if your project is not already a git repository, as a prerequisite for the manual installation steps. ```bash $ git init ``` -------------------------------- ### CocoaPods installation for Moya and reactive extensions Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/Moya/Readme.md CocoaPods Podfile entries for Moya and its reactive extensions. Choose one of the four variants depending on whether you need plain Moya, RxSwift, ReactiveSwift, or Combine support. After adding the entry, run `pod install` and import the framework with `import Moya`. ```ruby pod 'Moya', '~> 15.0' # or pod 'Moya/RxSwift', '~> 15.0' # or pod 'Moya/ReactiveSwift', '~> 15.0' #or pod 'Moya/Combine', '~> 15.0' ``` -------------------------------- ### Start Docker environment with docker-compose Source: https://github.com/easychen/pushdeer/blob/main/README.md Starts the API using Docker Compose. The default access address is http://127.0.0.1:8800, and the port can be adjusted by modifying docker-compose.yml. ```bash docker-compose up -d ``` -------------------------------- ### Add Alamofire and Moya as git submodules Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/Moya/Readme.md Run these commands to add Alamofire and Moya as git submodules for manual installation. ```bash $ git submodule add https://github.com/Alamofire/Alamofire.git $ git submodule add https://github.com/Moya/Moya.git ``` -------------------------------- ### Build Gorush from source Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Clones the Gorush repository and installs it using Go modules. ```sh mkdir $HOME/src cd $HOME/src git clone https://github.com/appleboy/gorush.git cd gorush go install ``` -------------------------------- ### Install PromiseKit with CocoaPods in Podfile Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/PromiseKit/README.md Add this to your Podfile to install PromiseKit via CocoaPods. The target name must match your Xcode project's target. Using use_frameworks! is required for Swift projects. ```ruby use_frameworks! target "Change Me!" do pod "PromiseKit", "~> 6.8" end ``` -------------------------------- ### GET /api/stat/app response example Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example JSON response from GET /api/stat/app, showing notification success and failure counts for iOS, Android, and Huawei platforms. ```json { "version": "v1.6.2", "queue_max": 8192, "queue_usage": 0, "total_count": 77, "ios": { "push_success": 19, "push_error": 38 }, "android": { "push_success": 10, "push_error": 10 }, "huawei": { "push_success": 3, "push_error": 1 } } ``` -------------------------------- ### Install Gorush via Homebrew Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Installs Gorush on macOS using Homebrew from the development formula. ```sh brew install --HEAD https://github.com/appleboy/gorush/raw/master/HomebrewFormula/gorush.rb ``` -------------------------------- ### GET /login/fake Source: https://github.com/easychen/pushdeer/blob/main/README.md 模拟登入接口,用于开发调试,仅在APP_DEBUG=true时可用。 ```APIDOC ## [GET] /login/fake ### Description 模拟登入接口,仅在环境变量APP_DEBUG=true时可用。 ### Method GET ### Endpoint /login/fake ### Parameters 无 ### Response #### Success Response (200) 返回通用格式,content中包含token。 #### Response Example { "code": 0, "content": { "token": "string" } } ``` -------------------------------- ### Run gorush with MIPUSH configuration Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Starts the gorush server with the specified configuration file. The configuration file must include the MIPUSH section for the push service to work. ```bash ./gorush -c ./config/testdata/config.yml ``` -------------------------------- ### Register gorush init script with update-rc.d (start/stop priorities) Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/contrib/init/debian/README.md Create and remove System-V init script links so gorush starts in runlevels 2-5 at priority 20 and stops in runlevels 0,1,6 at priority 80. ```sh update-rc.d gorush start 20 2 3 4 5 . stop 80 0 1 6 . ``` -------------------------------- ### Enable MQTT service in docker-compose.self-hosted.yml Source: https://github.com/easychen/pushdeer/blob/main/iot/README.md Shows the docker-compose.self-hosted.yml configuration before and after enabling the MQTT service. Set MQTT_ON=true and uncomment the mqtt service block, ensuring MQTT_API_KEY matches the API_KEY in the mqtt environment. Then start the service with the provided docker-compose command. ```yml app: #image: 'webdevops/php-apache:8.0-alpine' build: './docker/web/' ports: - '8800:80' volumes: - './:/app' depends_on: - mariadb - redis environment: - DB_HOST=mariadb - DB_PORT=3306 - DB_USERNAME=root - DB_DATABASE=pushdeer - DB_PASSWORD=theVeryp@ssw0rd - GO_PUSH_IOS_TOPIC=com.pushdeer.self.ios - GO_PUSH_IOS_CLIP_TOPIC=com.pushdeer.self.ios.Clip - APP_DEBUG=false - MQTT_API_KEY=9LKo3 - MQTT_ON=false <---- 这里改为 true # 下边去掉注释 # mqtt: # image: 'ccr.ccs.tencentyun.com/ftqq/pushdeeresp' # ports: # - '1883:1883' # environment: # - API_KEY=9LKo3 <---- 这里和上边的MQTT_API_KEY值一致 # - MQTT_PORT=1883 # - MQTT_USER=easy <---- 自己起一个用户名 # - MQTT_PASSWORD=y0urp@ss <---- 自己起一个密码 # - MQTT_BASE_TOPIC=default ``` ```yml - MQTT_API_KEY=2134grt - MQTT_ON=true mqtt: image: 'ccr.ccs.tencentyun.com/ftqq/pushdeeresp' ports: - '1883:1883' environment: - API_KEY=2134grt - MQTT_PORT=1883 - MQTT_USER=mynameisLili - MQTT_PASSWORD=howoldareU - MQTT_BASE_TOPIC=default ``` -------------------------------- ### Docker-compose deployment commands (GitHub and Gitee) Source: https://github.com/easychen/pushdeer/blob/main/README.md Commands to deploy PushDeer server via Docker-compose. The first uses GitHub, the second uses Gitee as an alternative but may not be up-to-date. Ensure docker-compose is installed; prefix with sudo if needed. ```bash git clone https://github.com/easychen/pushdeer.git cd pushdeer docker-compose -f docker-compose.self-hosted.yml up --build -d ``` ```bash git clone https://gitee.com/easychen/pushdeer.git cd pushdeer docker-compose -f docker-compose.self-hosted.yml up --build -d ``` -------------------------------- ### Run gorush web server Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Starts the gorush web server. Requires a config.yml file; the default port is 8088. Use -c to specify a custom config file. ```bash # for default config $ gorush # for custom config file $ gorush -c config.yml ``` -------------------------------- ### GET /api/config Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Retrieves the server's YAML configuration file. ```APIDOC ## [GET] /api/config ### Description Show server yml config file. ### Method GET ### Endpoint /api/config ### Response #### Success Response (200) - **config** (object) - The server configuration in YAML format. #### Response Example (No example provided in source) ``` -------------------------------- ### Get Go status with httpie Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Gets Go runtime statistics from the gorush API server using httpie. The -v flag shows verbose output, --verify=no disables SSL verification, and --json formats the response as JSON. ```bash http -v --verify=no --json GET http://localhost:8088/api/stat/go ``` -------------------------------- ### GET /metrics Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Exposes Prometheus metrics for monitoring. ```APIDOC ## [GET] /metrics ### Description Support expose prometheus metrics. ### Method GET ### Endpoint /metrics ### Response #### Success Response (200) - **metrics** (string) - Prometheus metrics in text format. #### Response Example (No example provided in source) ``` -------------------------------- ### GET /api/stat/go Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Retrieves Go runtime statistics including CPU, memory, and garbage collection information. ```APIDOC ## [GET] /api/stat/go ### Description Golang cpu, memory, gc, etc information. Response with `200` http status code. ### Method GET ### Endpoint /api/stat/go ### Response #### Success Response (200) - **time** (int) - Time of the stats. - **go_version** (string) - Go version. - **go_os** (string) - Operating system. - **go_arch** (string) - Architecture. - **cpu_num** (int) - Number of CPUs. - **goroutine_num** (int) - Number of goroutines. - **gomaxprocs** (int) - GOMAXPROCS setting. - **cgo_call_num** (int) - Number of cgo calls. - **memory_alloc** (int) - Allocated memory. - **memory_total_alloc** (int) - Total allocated memory. - **memory_sys** (int) - System memory. - **memory_lookups** (int) - Memory lookups. - **memory_mallocs** (int) - Memory mallocs. - **memory_frees** (int) - Memory frees. - **memory_stack** (int) - Stack memory. - **heap_alloc** (int) - Heap allocated. - **heap_sys** (int) - Heap system. - **heap_idle** (int) - Heap idle. - **heap_inuse** (int) - Heap in use. - **heap_released** (int) - Heap released. - **heap_objects** (int) - Heap objects. - **gc_next** (int) - Next GC target. - **gc_last** (int) - Last GC time. - **gc_num** (int) - Number of GCs. - **gc_per_second** (float) - GCs per second. - **gc_pause_per_second** (float) - GC pause per second. - **gc_pause** (array) - GC pause times. #### Response Example { "time": 1460686815848046600, "go_version": "go1.6.1", "go_os": "darwin", "go_arch": "amd64", "cpu_num": 4, "goroutine_num": 15, "gomaxprocs": 4, "cgo_call_num": 1, "memory_alloc": 7455192, "memory_total_alloc": 8935464, "memory_sys": 12560632, "memory_lookups": 17, "memory_mallocs": 31426, "memory_frees": 11772, "memory_stack": 524288, "heap_alloc": 7455192, "heap_sys": 8912896, "heap_idle": 909312, "heap_inuse": 8003584, "heap_released": 0, "heap_objects": 19654, "gc_next": 9754725, "gc_last": 1460686815762559700, "gc_num": 2, "gc_per_second": 0, "gc_pause_per_second": 0, "gc_pause": [ 0.326576, 0.227096 ] } ``` -------------------------------- ### GET /sys/stats Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Retrieves server statistics including response times and status code counts. ```APIDOC ## [GET] /sys/stats ### Description Show response time, status code count, etc. ### Method GET ### Endpoint /sys/stats ### Response #### Success Response (200) - **pid** (int) - Process ID. - **uptime** (string) - Uptime duration. - **uptime_sec** (float) - Uptime in seconds. - **time** (string) - Current time. - **unixtime** (int) - Unix timestamp. - **status_code_count** (object) - Status code counts for current interval. - **total_status_code_count** (object) - Total status code counts. - **count** (int) - Request count for current interval. - **total_count** (int) - Total request count. - **total_response_time** (string) - Total response time. - **total_response_time_sec** (float) - Total response time in seconds. - **average_response_time** (string) - Average response time. - **average_response_time_sec** (float) - Average response time in seconds. #### Response Example { "pid": 80332, "uptime": "1m42.428010614s", "uptime_sec": 102.428010614, "time": "2016-06-26 12:27:11.675973571 +0800 CST", "unixtime": 1466915231, "status_code_count": { }, "total_status_code_count": { "200": 5 }, "count": 0, "total_count": 5, "total_response_time": "10.422441ms", "total_response_time_sec": 0.010422441000000001, "average_response_time": "2.084488ms", "average_response_time_sec": 0.0020844880000000002 } ``` -------------------------------- ### POST /api/push Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Documentation for the POST /api/push endpoint, including request body parameters and examples for sending notifications to iOS, Android, and Huawei devices. ```APIDOC ## POST /api/push ### Description Send push notifications to iOS, Android, or Huawei devices. The request body must contain a notifications array, each element specifying tokens, platform, and message. Supports multiple notifications in a single request. ### Method POST ### Endpoint /api/push ### Parameters #### Request Body - **notifications** (array) - Required - Array of notification objects. Each object contains: - **notif_id** (string) - Optional - A unique string that identifies the notification for async feedback. - **tokens** (string array) - Required - Device tokens. - **platform** (int) - Required - Platform identifier: 1=iOS, 2=Android (Firebase), 3=Huawei (HMS). - **message** (string) - Optional - Message for notification. - **title** (string) - Optional - Notification title. - **priority** (string) - Optional - Sets the priority of the message. Values: `normal` or `high`. - **content_available** (bool) - Optional - Data messages wake the app by default. - **sound** (interface{}) - Optional - Sound type. - **data** (string array) - Optional - Extensible partition. Only Android and iOS. - **huawei_data** (string) - Optional - JSON object as string to extensible partition. Only Huawei. - **retry** (int) - Optional - Retry send notification if fail response from server. Value must be smaller than `max_retry` field. - **topic** (string) - Optional - Send messages to topics. - **image** (string) - Optional - Image URL to show in notification. Only Android and Huawei. ### Request Example { "notifications": [ { "tokens": ["token_a", "token_b"], "platform": 1, "message": "Hello World iOS!" } ] } ### Response #### Success Response (200) No response body documented. #### Response Example No response example provided. ``` -------------------------------- ### PromiseKit URLSession networking example with JSON decoding Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/PromiseKit/README.md Shows a PromiseKit chain using URLSession with the Foundation extension. It uses `.validate()` to convert HTTP errors like 404s into errors, decodes JSON with `JSONDecoder`, and includes a helper to build a POST request with JSON body. ```swift // pod 'PromiseKit/Foundation' # https://github.com/PromiseKit/Foundation firstly { URLSession.shared.dataTask(.promise, with: try makeUrlRequest()).validate() // ^^ we provide `.validate()` so that eg. 404s get converted to errors }.map { try JSONDecoder().decode(Foo.self, with: $0.data) }.done { foo in //… }.catch { error in //… } func makeUrlRequest() throws -> URLRequest { var rq = URLRequest(url: url) rq.httpMethod = "POST" rq.addValue("application/json", forHTTPHeaderField: "Content-Type") rq.addValue("application/json", forHTTPHeaderField: "Accept") rq.httpBody = try JSONEncoder().encode(obj) return rq } ``` -------------------------------- ### GET /api/stat/app Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Retrieves notification success and failure counts for iOS, Android, and Huawei platforms. ```APIDOC ## [GET] /api/stat/app ### Description Show success or failure counts information of notification. ### Method GET ### Endpoint /api/stat/app ### Response #### Success Response (200) - **version** (string) - Version of the server. - **queue_max** (int) - Maximum queue size. - **queue_usage** (int) - Current queue usage. - **total_count** (int) - Total number of notifications. - **ios** (object) - iOS push statistics. - **push_success** (int) - Number of successful pushes. - **push_error** (int) - Number of failed pushes. - **android** (object) - Android push statistics. - **push_success** (int) - Number of successful pushes. - **push_error** (int) - Number of failed pushes. - **huawei** (object) - Huawei push statistics. - **push_success** (int) - Number of successful pushes. - **push_error** (int) - Number of failed pushes. #### Response Example { "version": "v1.6.2", "queue_max": 8192, "queue_usage": 0, "total_count": 77, "ios": { "push_success": 19, "push_error": 38 }, "android": { "push_success": 10, "push_error": 10 }, "huawei": { "push_success": 3, "push_error": 1 } } ``` -------------------------------- ### iOS sound payload request format Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example request payload for setting the iOS sound dictionary with critical, name, and volume values. ```json { "sound": { "critical": 1, "name": "default", "volume": 2.0 } } ``` -------------------------------- ### PromiseKit Alamofire networking example with responseDecodable Source: https://github.com/easychen/pushdeer/blob/main/ios/Prototype_version/Pods/PromiseKit/README.md Shows a PromiseKit chain using Alamofire with the Alamofire extension. It performs a POST request and decodes the response directly into a `Foo` type using `responseDecodable`. ```swift // pod 'PromiseKit/Alamofire' # https://github.com/PromiseKit/Alamofire- firstly { Alamofire .request("http://example.com", method: .post, parameters: params) .responseDecodable(Foo.self) }.done { foo in //… }.catch { error in //… } ``` -------------------------------- ### gorush configuration YAML (config/testdata/config.yml) Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Complete gorush configuration file (config/testdata/config.yml) covering core HTTP server, gRPC, API endpoints, Android/Huawei/iOS push settings, queue engines (local, nsq, nats, redis), logging, and statistics backends (memory, redis, boltdb, buntdb, leveldb, badgerdb). Defaults are shown inline; for example, queue engine defaults to "local" and stat engine to "memory". Set sync or feedback_hook_url to receive error messages from failed push notifications. ```yaml core: enabled: true # enable httpd server address: "" # ip address to bind (default: any) shutdown_timeout: 30 # default is 30 second port: "8088" # ignore this port number if auto_tls is enabled (listen 443). worker_num: 0 # default worker number is runtime.NumCPU() queue_num: 0 # default queue number is 8192 max_notification: 100 sync: false # set true if you need get error message from fail push notification in API response. feedback_hook_url: "" # set a hook url if you need get error message asynchronously from fail push notification in API response. feedback_timeout: 10 # default is 10 second mode: "release" ssl: false cert_path: "cert.pem" key_path: "key.pem" cert_base64: "" key_base64: "" http_proxy: "" pid: enabled: false path: "gorush.pid" override: true auto_tls: enabled: false # Automatically install TLS certificates from Let's Encrypt. folder: ".cache" # folder for storing TLS certificates host: "" # which domains the Let's Encrypt will attempt grpc: enabled: false # enable gRPC server port: 9000 api: push_uri: "/api/push" stat_go_uri: "/api/stat/go" stat_app_uri: "/api/stat/app" config_uri: "/api/config" sys_stat_uri: "/sys/stats" metric_uri: "/metrics" health_uri: "/healthz" android: enabled: true apikey: "YOUR_API_KEY" max_retry: 0 # resend fail notification, default value zero is disabled huawei: enabled: false appsecret: "YOUR_APP_SECRET" appid: "YOUR_APP_ID" max_retry: 0 # resend fail notification, default value zero is disabled queue: engine: "local" # support "local", "nsq", "nats" and "redis" default value is "local" nsq: addr: 127.0.0.1:4150 topic: gorush channel: gorush nats: addr: 127.0.0.1:4222 subj: gorush queue: gorush redis: addr: 127.0.0.1:6379 channel: gorush size: 1024 ios: enabled: false key_path: "key.pem" key_base64: "" # load iOS key from base64 input key_type: "pem" # could be pem, p12 or p8 type password: "" # certificate password, default as empty string. production: false max_concurrent_pushes: 100 # just for push ios notification max_retry: 0 # resend fail notification, default value zero is disabled key_id: "" # KeyID from developer account (Certificates, Identifiers & Profiles -> Keys) team_id: "" # TeamID from developer account (View Account -> Membership) log: format: "string" # string or json access_log: "stdout" # stdout: output to console, or define log path like "log/access_log" access_level: "debug" error_log: "stderr" # stderr: output to console, or define log path like "log/error_log" error_level: "error" hide_token: true stat: engine: "memory" # support memory, redis, boltdb, buntdb or leveldb redis: cluster: false addr: "localhost:6379" # if cluster is true, you may set this to "localhost:6379,localhost:6380,localhost:6381" password: "" db: 0 boltdb: path: "bolt.db" bucket: "gorush" buntdb: path: "bunt.db" leveldb: path: "level.db" badgerdb: path: "badger.db" ``` -------------------------------- ### Success response body Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example of a successful response from the gorush API. The `counts` field shows the number of notifications sent, `logs` is empty, and `success` is "ok". ```json { "counts": 60, "logs": [], "success": "ok" } ``` -------------------------------- ### Error response body with logs Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example of a response body containing error logs for failed push notifications. Each log entry includes the platform, token, message, and error details. ```json { "counts": 60, "logs": [ { "type": "failed-push", "platform": "android", "token": "*******", "message": "Hello World Android!", "error": "InvalidRegistration" }, { "type": "failed-push", "platform": "ios", "token": "*****", "message": "Hello World iOS1111!", "error": "Post https://api.push.apple.com/3/device/bbbbb: remote error: tls: revoked certificate" }, { "type": "failed-push", "platform": "ios", "token": "*******", "message": "Hello World iOS222!", "error": "Post https://api.push.apple.com/3/device/token_b: remote error: tls: revoked certificate" } ], "success": "ok" } ``` -------------------------------- ### Send single notification via gRPC in Go Source: https://github.com/easychen/pushdeer/blob/main/push/gorush-with-mipush/src/README.md Example Go client that sends a single notification to the Gorush gRPC service. It connects to localhost:9000, builds a NotificationRequest with platform, tokens, message, badge, category, sound, priority, alert, and data fields, then calls Send and logs the success and count from the response. ```go package main import ( "context" "log" "github.com/appleboy/gorush/rpc/proto" structpb "github.com/golang/protobuf/ptypes/struct" "google.golang.org/grpc" ) const ( address = "localhost:9000" ) func main() { // Set up a connection to the server. conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Fatalf("did not connect: %v", err) } defer conn.Close() c := proto.NewGorushClient(conn) r, err := c.Send(context.Background(), &proto.NotificationRequest{ Platform: 2, Tokens: []string{"1234567890"}, Message: "test message", Badge: 1, Category: "test", Sound: "test", Priority: proto.NotificationRequest_HIGH, Alert: &proto.Alert{ Title: "Test Title", Body: "Test Alert Body", Subtitle: "Test Alert Sub Title", LocKey: "Test loc key", LocArgs: []string{"test", "test"}, }, Data: &structpb.Struct{ Fields: map[string]*structpb.Value{ "key1": { Kind: &structpb.Value_StringValue{StringValue: "welcome"}, }, "key2": { Kind: &structpb.Value_NumberValue{NumberValue: 2}, }, }, }, }) if err != nil { log.Println("could not greet: ", err) } if r != nil { log.Printf("Success: %t\n", r.Success) log.Printf("Count: %d\n", r.Counts) } } ``` -------------------------------- ### 启用 User_Setup.h 配置 Source: https://github.com/easychen/pushdeer/blob/main/iot/README.md 在 TFT_eSPI.h 中打开 User_select.h 的注释,确保包含 User_Setup.h 并注释掉 User_Setup_Select.h,以使用自定义的屏幕配置。 ```cpp #include // #include ``` -------------------------------- ### 注释默认 TFT 驱动 ILI9341_DRIVER Source: https://github.com/easychen/pushdeer/blob/main/iot/README.md 在 User_Setup.h 中注释或删除默认驱动(如 ILI9341_DRIVER)及其他内容,以便添加新的屏幕驱动配置。 ```cpp //#define ILI9341_DRIVER ``` -------------------------------- ### 启动服务(自架版) Source: https://github.com/easychen/pushdeer/blob/main/doc/调试文档.md 使用 docker-compose -f docker-compose.self-hosted.yml up --build 启动服务,去掉 -d 参数以在前台查看详细日志。 ```bash docker-compose -f docker-compose.self-hosted.yml up --build ``` -------------------------------- ### 命令行推送测试 Source: https://github.com/easychen/pushdeer/blob/main/doc/调试文档.md 在容器内使用 gorush 命令进行推送测试,需要替换 DeviceToken 为实际设备令牌。 ```bash cd /app/push && /data/gorush -ios -m "推送内容" -c "ios.yml" --topic "com.pushdeer.self.ios" -t "DeviceToken" --production ``` -------------------------------- ### 查看容器列表 Source: https://github.com/easychen/pushdeer/blob/main/doc/调试文档.md 使用 sudo docker ps 查看运行中的容器,获取 app_1 对应的容器 id。 ```bash sudo docker ps ``` -------------------------------- ### Run pushdeeresp Docker container Source: https://github.com/easychen/pushdeer/blob/main/iot/README.md Run the pushdeeresp Docker image to set up a standalone server for smart devices. Configure the API key, MQTT port, user, password, and base topic via environment variables, and map ports 1883 and 80. After startup, messages can be sent via MQTT or HTTP (IP/send). ```bash docker run -e API_KEY=9LKo3 -e MQTT_PORT=1883 -e MQTT_USER=easy -e MQTT_PASSWORD=y0urp@ss -e MQTT_BASE_TOPIC=default -p 1883:1883 -p 80:80 ccr.ccs.tencentyun.com/ftqq/pushdeeresp ``` -------------------------------- ### 进入容器 Source: https://github.com/easychen/pushdeer/blob/main/doc/调试文档.md 使用 sudo docker exec -it /bin/bash 进入容器,以便进行推送调试。 ```bash sudo docker exec -it /bin/bash ``` -------------------------------- ### docker-compose.yml 线上环境配置 Source: https://github.com/easychen/pushdeer/blob/main/doc/安装文档.md 用于线上部署的 docker-compose.yml 配置,包含 Redis 和 app 服务,并设置数据库、调试和推送相关环境变量。 ```yaml version: '2' services: redis: image: 'bitnami/redis:6.0.16' environment: - ALLOW_EMPTY_PASSWORD=yes app: #image: 'webdevops/php-apache:8.0-alpine' build: './docker/web/' ports: - '80:80' - '443:443' # 开放 https 需要的接口 depends_on: - redis volumes: - './:/app' environment: - DB_DATABASE=pushdeer - DB_HOST=clouddb.com - DB_PASSWORD=thep@ssw0rd - DB_PORT=3306 - DB_TIMEZONE=+08:00 - DB_USERNAME=pushdeer - APP_DEBUG=false - GO_PUSH_IOS_TOPIC=com.pushdeer.self.ios - GO_PUSH_IOS_CLIP_TOPIC=com.pushdeer.self.ios.Clip ```