SendPush
The SendPush method sends a push notification to a user's registered device.
Usage
err := client.SendPush(ctx, payload)
Parameters
| Name | Type | Description |
|---|---|---|
ctx | context.Context | Context for the request. |
payload | cdp.PushPayload | Struct containing push notification details. |
PushPayload Struct
| Field | Type | Required | Description |
|---|---|---|---|
Identifiers | cdp.Identifiers | ✅ | User identifiers (exactly one of ID, Email, or CioID). |
TransactionalMessageID | string | ✅ | ID of the push message template. |
Title | string | Notification title (overrides template). | |
Body | string | Notification body text (overrides template). | |
MessageData | map[string]interface{} | Data for template variables or deep linking. |
Validation Rules
Identifiersmust contain exactly one of:ID,Email, orCioIDTransactionalMessageIDis requiredBodycannot be an empty string if provided
Dual-Write Behavior
Push NOT Forwarded to Customer.io
Push notifications are not sent to Customer.io even when dual-write is enabled. This prevents duplicate notifications.
Example
payload := cdp.PushPayload{
Identifiers: cdp.Identifiers{ID: "user_123"},
TransactionalMessageID: "promo_push",
Title: "Flash Sale!",
Body: "50% off everything today.",
MessageData: map[string]interface{}{
"deep_link": "app://sale/50off",
},
}
if err := client.SendPush(context.Background(), payload); err != nil {
log.Println("Error sending push:", err)
}