Configure push notification attributes for messages
When sending a message, use NCPushConfig within NCSendMessageParams to customize the push notification behavior for that individual message. For example:
- Customize push notification content (
pushContent) - Add extra data to the remote push notification (
pushData) - Disable push notifications for the message (
disableNotification)
Objective C
NCTextMessage *textContent = [[NCTextMessage alloc] initWithText:@"Test text message"];
NCSendMessageParams *params = [[NCSendMessageParams alloc] initWithContent:textContent];
// Customize push notification properties
NCPushConfig *pushConfig = [[NCPushConfig alloc] init];
pushConfig.pushContent = @"Notification content";
pushConfig.pushData = @"Additional pushData for the notification";
params.pushConfig = pushConfig;
// To disable push notifications for this message:
// params.disableNotification = YES;
NCDirectChannel *channel = [[NCDirectChannel alloc] initWithChannelId:@"targetUserId"];
[channel sendMessageWithParams:params attachedHandler:^(NCMessage * _Nullable message) {
// Message saved to local DB
} completionHandler:^(NCMessage * _Nullable sentMessage, NCError * _Nullable error) {
// Handle send result
}];
Message push property reference
NCPushConfig properties (set via NCSendMessageParams.pushConfig)
| Property | Type | Description |
|---|---|---|
pushTitle | NSString * | Push notification title. nil uses the default title. |
pushContent | NSString * | Push notification content. When set, overrides the default push content for the message type. nil uses the default. |
pushData | NSString * | Additional data attached to the remote push notification. Accessible from the push notification payload. |
disablePushTitle | BOOL | Whether to hide the push notification title for this message. When YES, only the body is shown. |
forceShowDetailContent | BOOL | Whether to force showing notification content even when recipient has opted to hide message details. Default NO. |
templateId | NSString * | Push template ID for localized push content. |
iOSConfig | NCIOSPushConfig * | iOS-specific push configuration (APNs thread ID, collapse ID, etc.). |
NCSendMessageParams push-related properties
| Property | Type | Description |
|---|---|---|
pushConfig | NCPushConfig * | Per-message push configuration. nil uses the default push strategy. |
disableNotification | BOOL | Whether to disable remote push and local notifications. Defaults to NO. |
needReceipt | BOOL | Whether a read receipt is required. |