Apple Push Notification Service binding spec

有关 Apple 推送通知服务绑定组件的详细文档

Component format

To setup Apple Push Notifications binding create a component of type bindings.apns. See this guide on how to create and apply a binding configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.apns
  8. version: v1
  9. metadata:
  10. - name: development
  11. value: <bool>
  12. - name: key-id
  13. value: <APPLE_KEY_ID>
  14. - name: team-id
  15. value: <APPLE_TEAM_ID>
  16. - name: private-key
  17. secretKeyRef:
  18. name: <SECRET>
  19. key: <SECRET-KEY-NAME>

Spec metadata fields

字段RequiredBinding supportDetailsExample
developmentYOutputTells the binding which APNs service to use. 设置为 true 以用于开发环境, false 用于生产环境。 Default: “true”“true”
key-idYOutputkey-id 是 Apple Developer Portal中专用密钥的标识。“private-key-id
team-idYOutputThe identifier for the organization or author from the Apple Developer Portal“team-id”
private-keyYOutputIs a PKCS #8-formatted private key. It is intended that the private key is stored in the secret store and not exposed directly in the configuration. See here for more details“pem file”

Private key

The APNS binding needs a cryptographic private key in order to generate authentication tokens for the APNS service. The private key can be generated from the Apple Developer Portal and is provided as a PKCS #8 file with the private key stored in PEM format. The private key should be stored in the Dapr secret store and not stored directly in the binding’s configuration file.

A sample configuration file for the APNS binding is shown below:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: apns
  5. namespace: default
  6. spec:
  7. type: bindings.apns
  8. metadata:
  9. - name: development
  10. value: false
  11. - name: key-id
  12. value: PUT-KEY-ID-HERE
  13. - name: team-id
  14. value: PUT-APPLE-TEAM-ID-HERE
  15. - name: private-key
  16. secretKeyRef:
  17. name: apns-secrets
  18. key: private-key

If using Kubernetes, a sample secret configuration may look like this:

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: apns-secrets
  5. namespace: default
  6. stringData:
  7. private-key: |
  8. -----BEGIN PRIVATE KEY-----
  9. KEY-DATA-GOES-HERE
  10. -----END PRIVATE KEY-----

Output bindings

This component supports output binding with the following operations:

  • create

输出绑定支持的操作

The APNS binding is a pass-through wrapper over the Apple Push Notification Service. The APNS binding will send the request directly to the APNS service without any translation. It is therefore important to understand the payload for push notifications expected by the APNS service. The payload format is documented here.

Request format

  1. {
  2. "data": {
  3. "aps": {
  4. "alert": {
  5. "title": "New Updates!",
  6. "body": "There are new updates for your review"
  7. }
  8. }
  9. },
  10. "metadata": {
  11. "device-token": "PUT-DEVICE-TOKEN-HERE",
  12. "apns-push-type": "alert",
  13. "apns-priority": "10",
  14. "apns-topic": "com.example.helloworld"
  15. },
  16. "operation": "create"
  17. }

The data object contains a complete push notification specification as described in the Apple documentation. The data object will be sent directly to the APNs service.

Besides the device-token value, the HTTP headers specified in the Apple documentation can be sent as metadata fields and will be included in the HTTP request to the APNs service.

Response format

  1. {
  2. "messageID": "UNIQUE-ID-FOR-NOTIFICATION"
  3. }

Related links

Last modified January 1, 0001