# Push

## Update the pusher for this device on the SDN node.

```objectivec
- (MXHTTPOperation*)setPusherWithPushkey:(NSString *)pushkey
                                    kind:(NSObject *)kind
                                   appId:(NSString *)appId
                          appDisplayName:(NSString *)appDisplayName
                       deviceDisplayName:(NSString *)deviceDisplayName
                              profileTag:(NSString *)profileTag
                                    lang:(NSString *)lang
                                    data:(NSDictionary *)data
                                  append:(BOOL)append
                                 success:(void (^)(void))success
                                 failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**:

| Name              | Type         | Description                                                                                                                                    | Required |
| ----------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| pushkey           | NSString     | The pushkey for this pusher. This should be the APNS token formatted as required for your push gateway (base64 is the recommended formatting). | True     |
| kind              | NSString     | The kind of pusher your push gateway requires. Generally 'http', or an NSNull to disable the pusher.                                           | false    |
| appId             | NSString     | The app ID of this application as required by your push gateway.                                                                               | True     |
| appDisplayName    | NSString     | A human readable display name for this app.                                                                                                    | True     |
| deviceDisplayName | NSString     | A human readable display name for this device.                                                                                                 | True     |
| profileTag        | NSString     | The profile tag for this device. Identifies this device in push rules.                                                                         | True     |
| lang              | NSString     | The user's preferred language for push, eg. 'en' or 'en-US'                                                                                    | True     |
| data              | NSDictionary | Dictionary of data as required by your push gateway (generally the notification URI and aps-environment for APNS).                             | True     |
| append            | BOOL         | If true, the node should add another pusher with the given pushkey and App ID in addition to any others with different user IDs.               | True     |

**Output Parameters**：

<table><thead><tr><th>Name</th><th width="81">Type</th><th width="376">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds. It provides credentials to use to create a MXRestClient.</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Update the pusher for this device on the node

```objectivec
- (MXHTTPOperation*)setPusherWithPushkey:(NSString *)pushkey
                                    kind:(NSObject *)kind
                                   appId:(NSString *)appId
                          appDisplayName:(NSString *)appDisplayName
                       deviceDisplayName:(NSString *)deviceDisplayName
                              profileTag:(NSString *)profileTag
                                    lang:(NSString *)lang
                                    data:(NSDictionary *)data
                                  append:(BOOL)append
                                 enabled:(BOOL)enabled
                                 success:(void (^)(void))success
                                 failure:(void (^)(NSError *))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**：

| Name              | Type         | Description                                                                                                                                    | Required |
| ----------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| pushkey           | NSString     | The pushkey for this pusher. This should be the APNS token formatted as required for your push gateway (base64 is the recommended formatting). | True     |
| kind              | NSString     | The kind of pusher your push gateway requires. Generally 'http', or an NSNull to disable the pusher.                                           | false    |
| appId             | NSString     | The app ID of this application as required by your push gateway.                                                                               | True     |
| appDisplayName    | NSString     | A human readable display name for this app.                                                                                                    | True     |
| deviceDisplayName | NSString     | A human readable display name for this device.                                                                                                 | True     |
| profileTag        | NSString     | The profile tag for this device. Identifies this device in push rules.                                                                         | True     |
| lang              | NSString     | The user's preferred language for push, eg. 'en' or 'en-US'                                                                                    | True     |
| data              | NSDictionary | Dictionary of data as required by your push gateway (generally the notification URI and aps-environment for APNS).                             | True     |
| append            | BOOL         | If true, the node should add another pusher with the given pushkey and App ID in addition to any others with different user IDs.               | True     |
| enabled           | BOOL         | Whether the pusher should actively create push notifications                                                                                   | True     |

**Output Parameters**：

<table><thead><tr><th>Name</th><th width="110">Type</th><th width="379">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds. It provides credentials to use to create a MXRestClient.</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Get all currently active pushers for the authenticated user

```Objective-C
- (MXHTTPOperation*)pushers:(void (^)(NSArray<MXPusher *> *pushers))success
                    failure:(void (^)(NSError *))failure NS_REFINED_FOR_SWIFT;

```

**Input Parameters**：None

**Output Parameters**：

| Name    | Type  | Description                                       | Required |
| ------- | ----- | ------------------------------------------------- | -------- |
| success | block | A block object called when the operation succeeds | true     |
| failure | block | A block object called when the operation fails.   | true     |

## Get all push notifications rules

```objectivec
- (MXHTTPOperation*)pushRules:(void (^)(MXPushRulesResponse *pushRules))success
                      failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**: None

**Output Parameters**：

<table><thead><tr><th width="122">Name</th><th width="119">Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>NSString</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>NSString</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Enable/Disable a push notification rule

```objectivec
- (MXHTTPOperation *)enablePushRule:(NSString*)ruleId
                              scope:(NSString*)scope
                               kind:(MXPushRuleKind)kind
                             enable:(BOOL)enable
                            success:(void (^)(void))success
                            failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**：

<table><thead><tr><th width="119">Name</th><th width="168">Type</th><th width="356">Description</th><th>Required</th></tr></thead><tbody><tr><td>ruleId</td><td>NSString</td><td>The identifier for the rule.</td><td>True</td></tr><tr><td>scope</td><td>NSString</td><td>Either 'global' or 'device/&#x3C;profile_tag>' to specify global rules or device rules for the given profile_tag.</td><td>false</td></tr><tr><td>kind</td><td>MXPushRuleKind</td><td>The kind of rule, ie. 'override', 'underride', 'sender', 'room', 'content' (see MXPushRuleKind).</td><td>True</td></tr><tr><td>enable</td><td>NSString</td><td>YES to enable</td><td>True</td></tr></tbody></table>

```objectivec
/**
 Push rules kind.
 
 Push rules are separated into different kinds of rules. These categories have a priority order: verride rules
 have the highest priority.
 Some category may define implicit conditions.
 */
typedef enum : NSUInteger
{
    MXPushRuleKindOverride,
    MXPushRuleKindContent,
    MXPushRuleKindRoom,
    MXPushRuleKindSender,
    MXPushRuleKindUnderride
} MXPushRuleKind NS_REFINED_FOR_SWIFT;
```

**Output Parameters**：

<table><thead><tr><th width="124">Name</th><th width="101">Type</th><th width="413">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Remove a push notification rule

```objectivec
- (MXHTTPOperation *)removePushRule:(NSString*)ruleId
                              scope:(NSString*)scope
                               kind:(MXPushRuleKind)kind
                            success:(void (^)(void))success
                            failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**：

<table><thead><tr><th width="118">Name</th><th width="183">Type</th><th width="347">Description</th><th>Required</th></tr></thead><tbody><tr><td>ruleId</td><td>NSString</td><td>The identifier for the rule.</td><td>True</td></tr><tr><td>scope</td><td>NSString</td><td>Either 'global' or 'device/&#x3C;profile_tag>' to specify global rules or device rules for the given profile_tag.</td><td>false</td></tr><tr><td>kind</td><td>MXPushRuleKind</td><td>The kind of rule, ie. 'override', 'underride', 'sender', 'room', 'content' (see MXPushRuleKind).</td><td>True</td></tr></tbody></table>

**Output Parameters**：

<table><thead><tr><th width="119">Name</th><th width="111">Type</th><th width="390">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Create a new push rule

```objectivec
- (MXHTTPOperation *)addPushRule:(NSString*)ruleId
                           scope:(NSString*)scope
                            kind:(MXPushRuleKind)kind
                         actions:(NSArray*)actions
                         pattern:(NSString*)pattern
                      conditions:(NSArray<NSDictionary *> *)conditions
                         success:(void (^)(void))success
                         failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**：

<table><thead><tr><th width="109">Name</th><th width="180">Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>ruleId</td><td>NSString</td><td>The identifier for the rule (it depends on rule kind: user id for sender rule, room id for room rule...).</td><td>True</td></tr><tr><td>scope</td><td>NSString</td><td>Either 'global' or 'device/&#x3C;profile_tag>' to specify global rules or device rules for the given profile_tag.</td><td>false</td></tr><tr><td>kind</td><td>MXPushRuleKind</td><td>The kind of rule, ie. 'sender', 'room' or 'content' (see MXPushRuleKind).</td><td>True</td></tr><tr><td>actions</td><td>NSArray</td><td>The rule actions: notify, don't notify, set tweak...</td><td>True</td></tr><tr><td>pattern</td><td>NSString</td><td>The pattern relevant for content rule.</td><td>True</td></tr><tr><td>conditions</td><td>NSArray</td><td>The conditions relevant for override and underride rule.</td><td>True</td></tr></tbody></table>

**Output Parameters**：

<table><thead><tr><th width="145">Name</th><th width="95">Type</th><th width="399">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Update push rule actions

```objectivec
- (MXHTTPOperation *)updateActionsForPushRule:(NSString*)ruleId
                                        scope:(NSString*)scope
                                         kind:(MXPushRuleKind)kind
                                      actions:(NSArray*)actions
                                      success:(void (^)(void))success
                                      failure:(void (^)(NSError *error))failure;
```

**Input Parameters**：

<table><thead><tr><th width="115">Name</th><th width="172">Type</th><th width="364">Description</th><th>Required</th></tr></thead><tbody><tr><td>ruleId</td><td>NSString</td><td>The identifier for the rule (it depends on rule kind: user id for sender rule, room id for room rule...).</td><td>True</td></tr><tr><td>scope</td><td>NSString</td><td>Either 'global' or 'device/&#x3C;profile_tag>' to specify global rules or device rules for the given profile_tag.</td><td>false</td></tr><tr><td>kind</td><td>MXPushRuleKind</td><td>The kind of rule, ie. 'sender', 'room' or 'content' (see MXPushRuleKind).</td><td>True</td></tr><tr><td>actions</td><td>NSArray</td><td>The rule actions: notify, don't notify, set tweak...</td><td>True</td></tr></tbody></table>

**Output Parameters**：

<table><thead><tr><th width="128">Name</th><th width="100">Type</th><th width="425">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>block</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>block</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sending-network.gitbook.io/sending.network/sdk-documentation/ios-client-sdk/push.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
