APNs Channel Provider
Configuration
The configuration steps are explained in the apns configuration page.
APNs Token
Parameter | Type | Required(*) | Description |
---|---|---|---|
installation_id | string | (Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`. | |
app_id | string | (Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration. | |
device_token | string | * |
Example
{
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"installation_id": "development"
}
Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"app_id": {
"description": "(Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration.",
"pattern": "^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$",
"type": "string"
},
"device_token": {
"minLength": 64,
"type": "string"
},
"installation_id": {
"description": "(Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in `production`.",
"enum": [
"development",
"production"
],
"type": "string"
}
},
"required": [
"device_token"
],
"type": "object"
}
Usage
1. When configured with
{
"app_id": "com.example.myapp",
"badge": "unread",
"certificate": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgHnr4B2P+by++FGu/th0a44E8chJl5v5Vo4gq0YHw6e6gCgYIKoZIzj0DAQehRANCAARCg1MRibnfyeX5mx6+Rtfzzn7UhJP/oaqL4RzSmDuTsd3BTX33cuQ0gWHe20R2m1bLAkI1wrp+zbWOlAOAD7KX\n-----END PRIVATE KEY-----",
"key_id": "ABCD1234EF",
"team_id": "ABCD1234EF"
}
2. With a channel token
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"app_id": {
"description": "The default bundle identifier of the application that is configured with this project. It can be overriden on a per token basis, when registering device tokens.",
"pattern": "^[a-zA-Z0-9]+(.[a-zA-Z0-9]+)*$",
"type": "string"
},
"badge": {
"enum": [
"unread",
"unseen"
],
"type": "string"
},
"certificate": {
"description": "The APNs certificate in P8 format. Generate it at [developer.apple.com](https://developer.apple.com/account/resources/authkeys/add) with the 'Apple Push Notification service (APNs)' option selected.",
"pattern": "^-+?\\s?BEGIN PRIVATE KEY-+\\n([A-Za-z0-9+/\\r\\n]+={0,2})\\n-+\\s?END PRIVATE KEY+-+\\n?$",
"type": "string",
"x-ui": {
"tagName": "textarea"
}
},
"key_id": {
"maxLength": 10,
"minLength": 10,
"type": "string"
},
"payload_version": {
"default": "2",
"enum": [
"1",
"2"
],
"type": "string",
"x-ui": {
"type": "hidden"
}
},
"team_id": {
"maxLength": 10,
"minLength": 10,
"type": "string"
}
},
"required": [
"app_id",
"certificate",
"key_id",
"team_id",
"badge"
],
"type": "object"
}
3. With Broadcast
{
"action_url": "https://example.com",
"category": "example",
"content": "Hello, World!",
"custom_attributes": {},
"id": "d1b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
"overrides": {},
"recipients": [
{
"custom_attributes": {
"plan": "enterprise",
"preferred_pronoun": "They",
"pricing_version": "v10"
},
"email": "test@example.com",
"external_id": "83d987a-83fd034",
"first_name": "Person",
"last_name": "Doe",
"phone_numbers": [
"+1 5005550001"
]
}
],
"title": "Hello, World!",
"topic": "example"
}
The channel handler triggers a HTTP request
POST https://api.sandbox.push.apple.com/3/device/eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt
With payload
{
"action-url": "https://example.com",
"aps": {
"alert": {
"body": "Hello, World!",
"title": "Hello, World!"
}
},
"custom-attributes": {}
}
Overrides
The provider overrides key in the broadcast payload can be used to change the default behavior of the channel handler.
overrides >> providers >> apns
Override aps key
Overrides
{
"providers": {
"apns": {
"aps": {
"alert": {
"launch-image": "launch image",
"loc-args": [
"loc",
"args"
],
"loc-key": "loc key",
"title-loc-args": [
"title",
"loc",
"args"
],
"title-loc-key": "title loc key"
},
"content-available": 1,
"sound": "my_sound"
}
}
}
}
Payload
{
"aps": {
"alert": {
"launch-image": "launch image",
"loc-args": [
"loc",
"args"
],
"loc-key": "loc key",
"title": "notification title 1",
"title-loc-args": [
"title",
"loc",
"args"
],
"title-loc-key": "title loc key"
},
"content-available": 1,
"sound": "my_sound"
},
"custom-attributes": {}
}
Override mutable-content
Overrides
{
"providers": {
"apns": {
"mutable-content": 1
}
}
}
Payload
{
"action-url": "https://example.com/notifications/0194a896-64fb-79ab-b7a0-3289c2b79675",
"aps": {
"alert": {
"body": "Content body",
"title": "John Doe mentioned you in a PR"
}
},
"custom-attributes": {
"audience": "user",
"body": "Content body",
"document": {
"comment-id": "ff002c29-3279-4f60-a427-ea596412204a",
"document-id": "843c7692-39bd-41ed-b841-2a873f0a9b7c",
"slide-id": "bb951254-9388-4029-ae6d-003dde9c97df",
"workspace-id": "c0d4647a-0ee4-40ec-b9f5-334e567e7e02"
},
"html-body": "\\u003cp\\u003eContent body\\u003c/p\\u003e",
"html-title": "\\u003cb\\u003eJohn Doe\\u003c/b\\u003e mentioned you in \\u003cb\\u003ea PR\\u003c/b\\u003e",
"sender": {
"profile-picture-url": "https://example.com/profile/test-user.png",
"username": "John Doe"
},
"source": "direct",
"title": "John Doe mentioned you in a PR",
"type": "comment-mention"
}
}