Web API

Gorush support the following API.

  • GET /api/stat/app show notification success and failure counts.
  • POST /api/push push ios, android or huawei notifications.

API Example

Simple send notification on Android and iOS devices using Firebase, the platform value is 2:

{
  "notifications": [
    {
      "tokens": ["token_a", "token_b"],
      "platform": 2,
      "message": "This notification will go to iOS and Android platform via Firebase!"
    }
  ]
}

Send notification with custom sound on iOS devices, volume must be in the interval [0, 1]:

{
  "notifications": [
    {
      "tokens": ["token_a", "token_b"],
      "title": "Hello World iOS!",
      "message": "Hello World iOS!",
      "platform": 2,
      "apns": {
        "payload": {
          "aps": {
            "sound": {
              "name": "default",
              "critical": 1,
              "volume": 0.1
            }
          }
        }
      }
    }
  ]
}

Send multiple notifications as below:

{
  "notifications": [
    {
      "tokens": ["token_a", "token_b"],
      "platform": 2,
      "message": "Hello World iOS!"
    },
    {
      "tokens": ["token_a", "token_b"],
      "platform": 2,
      "message": "New World iOS!"
    },
    .....
  ]
}

Request body

The Request body must have a notifications array. The following is a parameter table for each notification.

nametypedescriptionrequirednote
notif_idstringA unique string that identifies the notification for async feedback-
tokensstring arraydevice tokenso
platformintplatform(iOS = 2)o1=iOS, 2=Android (Firebase), 3=Huawei (HMS)
messagestringmessage for notification-
titlestringnotification title-
prioritystringSets the priority of the message.-normal or high
content_availablebooldata messages wake the app by default.-
soundinterfacesound type-
datastring arrayextensible partition-only Android and IOS
huawei_datastringJSON object as string to extensible partition partition-only Huawei. See the detail
retryintretry send notification if fail response from server. Value must be small than max_retry field.-
topicstringsend messages to topics
imagestringimage url to show in notification-only Android and Huawei
tostringThe value must be a registration token, notification key, or topic.-only Android
collapse_keystringa key for collapsing notifications-only Android
delay_while_idleboola flag for device idling-only Android
time_to_liveuintexpiration of message kept on FCM storage-only Android
huawei_ttlstringexpiration of message kept on HMS storage-only Huawei See the detail
restricted_package_namestringthe package name of the application-only Android
dry_runboolallows developers to test a request without actually sending a message-only Android
notificationstring arraypayload of a FCM message-only Android. See the detail
huawei_notificationstring arraypayload of a HMS message-only Huawei. See the detail
app_idstringhms app id-only Huawei. See the detail
bi_tagstringTag of a message in a batch delivery task-only Huawei. See the detail
fast_app_targetintState of a mini program when a quick app sends a data message.-only Huawei. See the detail
expirationintexpiration for notification-only iOS
apns_idstringA canonical UUID that identifies the notification-only iOS
collapse_idstringAn identifier you use to coalesce multiple notifications into a single notification for the user-only iOS
push_typestringThe type of the notification. The value of this header is alert or background.-only iOS
badgeintbadge count-only iOS
categorystringthe UIMutableUserNotificationCategory object-only iOS
alertstring arraypayload of a iOS message-only iOS. See the detail
mutable_contentboolenable Notification Service app extension.-only iOS(10.0+).
namestringsets the name value on the aps sound dictionary.-only iOS
volumefloat32sets the volume value on the aps sound dictionary.-only iOS
interruption_levelstringdefines the interruption level for the push notification.-only iOS(15.0+)
content-statestring arraydynamic and custom content for live-activity notification.-only iOS(16.1+)
timestampintthe UNIX time when sending the remote notification that updates or ends a Live Activity-only iOS(16.1+)
eventstringdescribes whether you update or end an ongoing Live Activity-only iOS(16.1+)
stale-dateintthe date which a Live Activity becomes stale, or out of date-only iOS(16.1+)
dismissal-dateintthe UNIX time -timestamp- which a Live Activity will end and will be removed-only iOS(16.1+)

iOS alert payload

nametypedescriptionrequirednote
titlestringApple Watch & Safari display this string as part of the notification interface.-
bodystringThe text of the alert message.-
subtitlestringApple Watch & Safari display this string as part of the notification interface.-
actionstringThe label of the action button. This one is required for Safari Push Notifications.-
action-loc-keystringIf a string is specified, the system displays an alert that includes the Close and View buttons.-
launch-imagestringThe filename of an image file in the app bundle, with or without the filename extension.-
loc-argsarray of stringsVariable string values to appear in place of the format specifiers in loc-key.-
loc-keystringA key to an alert-message string in a Localizable.strings file for the current localization.-
title-loc-argsarray of stringsVariable string values to appear in place of the format specifiers in title-loc-key.-
title-loc-keystringThe key to a title string in the Localizable.strings file for the current localization.-

See more detail about APNs Remote Notification Payload.

iOS sound payload

nametypedescriptionrequirednote
namestringsets the name value on the aps sound dictionary.-
volumefloat32sets the volume value on the aps sound dictionary.-
criticalintsets the critical value on the aps sound dictionary.-

request format:

{
  "sound": {
    "critical": 1,
    "name": "default",
    "volume": 2.0
  }
}
curl --request POST \
  --url https://push.goldencrystalcrash.com/api/push \
  --header 'content-type: application/json' \
  --data '{
  "notifications": [
    {
      "tokens": [
        "dq6-MICVfkrYg3fgsp_7O5:APA91bE-3aMgO1QOgMJE4kchYZbvbvE3-Or-SyBh3Zu15193sExhq215yXIczQYSdjA6QK90SuNs_VkaKHD-49Qbi5RwpaCUQzIDnbq1Czb6xyqhY--W_pU",
        "fUwoMP5B40CTvR1NIPfK1w:APA91bFcpvPrM5ffx7Mp5AiIPW5PprE2yG8Qfr-QvMB1h2o75lHefqmh9vLFOSUtD9KdbuOAIZmoZLI-1ffuLHy5NHMu_NU43_ET33NIpELxBJPY38dHVnY"
      ],
      "platform": 2,
      "title": "title",
      "message": "Hello World android!",
      "apns": {
        "payload": {
          "aps": {
            "sound": {
              "name": "default",
              "critical": 1,
              "volume": 0.1
            }
          }
        }
      }
    }
  ]
}'