Skip to content

Commit

Permalink
Merge pull request #7849 from braze-inc/develop
Browse files Browse the repository at this point in the history
Leftover deploy - August 8, 2024
  • Loading branch information
lydia-xie authored Aug 8, 2024
2 parents 9df8c93 + 6097c8b commit 1b0778a
Show file tree
Hide file tree
Showing 48 changed files with 544 additions and 643 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ curl --location --request POST 'https://rest.iad-01.braze.com/canvas/trigger/sen

Message sending endpoint responses will include the message's `dispatch_id` for reference back to the dispatch of the message. The `dispatch_id` is the ID of the message dispatch (unique ID for each "transmission" sent from the Braze platform). Check out [Dispatch ID behavior]({{site.baseurl}}/help/help_articles/data/dispatch_id/) for more information.

### Example success response

The status code 201 could return the following response body. If the Canvas is archived, stopped, or paused, the Canvas will not be sent through this endpoint.

```
{
"notice": "The Canvas is paused. Resume the Canvas to ensure trigger requests will take effect.",
"dispatch_id": "example_dispatch_id",
"message": "success"
}
```

If your Canvas is archived, you'll see this `notice` message: "The Canvas is archived. Unarchive the Canvas to ensure trigger requests will take effect." If your Canvas is not active, you'll see this `notice` message: "The Canvas is paused. Resume the Canvas to ensure trigger requests will take effect."

## Create send endpoint

**Using the Attributes Object in Canvas**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ Content Cards will only refresh on session start if a subscribe request is calle
{% endtab %}
{% endtabs %}




## Logging events

Logging valuable metrics like impressions, clicks, and dismissals is quick and simple. Set a custom click listener to manually handle these analytics.
Expand Down Expand Up @@ -244,10 +241,14 @@ BrazeContentCardsManager.getInstance().contentCardsActionListener = object : ICo

{% endsubtab %}
{% endsubtabs %}

{% alert important %}
To handle control variant Content Cards in your custom UI, pass in your [`com.braze.models.cards.Card`](https://braze-inc.github.io/braze-android-sdk/kdoc/braze-android-sdk/com.braze.models.cards/-card/index.html) object, then call the `logImpression` method as you would with any other Content Card type. The object will implicitly log a control impression to inform our analytics of when a user would have seen the control card.{% endalert %}

{% endtab %}
{% tab iOS %}

Implement the [`BrazeContentCardUIViewControllerDelegate`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazeui/brazecontentcarduiviewcontrollerdelegate) protocol and set your delegate object as the `delegate` property of your `BrazeContentCardUI.ViewController`. This delegate will handle passing the data of your custom object back to Braze to be logged.
Implement the [`BrazeContentCardUIViewControllerDelegate`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazeui/brazecontentcarduiviewcontrollerdelegate) protocol and set your delegate object as the `delegate` property of your `BrazeContentCardUI.ViewController`. This delegate will handle passing the data of your custom object back to Braze to be logged. For an example, see [Content Cards UI tutorial](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c2-contentcardsui/).

{% subtabs local %}
{% subtab Swift %}
Expand Down Expand Up @@ -282,13 +283,14 @@ contentCardsController.delegate = delegate;
return YES;
}
```

{% endsubtab %}
{% endsubtabs %}

Refer to the [Content Cards UI tutorial](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c2-contentcardsui/) for an example.

{% alert important %}
To handle control variant Content Cards in your custom UI, pass in your [`Braze.ContentCard.Control`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/contentcard/control(_:)) object, then call the `logImpression` method as you would with any other Content Card type. The object will implicitly log a control impression to inform our analytics of when a user would have seen the control card.
{% endalert %}
{% endtab %}

{% tab Web %}

Log impression events when cards are viewed by users using [`logContentCardImpressions`](https://js.appboycdn.com/web-sdk/latest/doc/modules/braze.html#logcontentcardimpressions):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ channel:

# Content Card integration

> This reference article covers the Content Card integration and the different data models and card-specific properties available for your Swift application.
> This reference article covers the Content Card integration and the different data models and card-specific properties available for your Swift application. When you're ready to get started with implementation and customization, see the [Content Card Customization Guide]({{site.baseurl}}/developer_guide/customization_guides/content_cards).
{% alert note %}
When you're ready to get started with implementation and customization, see the [Content Card Customization Guide]({{site.baseurl}}/developer_guide/customization_guides/content_cards).
{% endalert %}
## About the integration

The default Content Cards UI can be integrated from the `BrazeUI` library of the Braze SDK. Create the Content Cards view controller using the `braze` instance. If you wish to intercept and react to the Content Card UI lifecycle, implement [`BrazeContentCardUIViewControllerDelegate`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazeui/brazecontentcarduiviewcontrollerdelegate) as the delegate for your `BrazeContentCardUI.ViewController`.

{% alert note %}
For more information about iOS view controller options, refer to the [Apple developer documentation](https://developer.apple.com/documentation/uikit/view_controllers/showing_and_hiding_view_controllers).
{% endalert %}

The `BrazeUI` library of the Swift SDK provides two default view controller contexts: navigation or modal. This means you can integrate Content Cards in these contexts by adding a few lines of code to your app or site. Both views offer customization and styling options as described in the [customization guide]({{site.baseurl}}/developer_guide/customization_guides/content_cards/customizing_styles/?tab=ios). You can also create a custom Content Card view controller instead of using the standard Braze one for even more customization options—refer to the [Content Cards UI tutorial](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c2-contentcardsui/) for an example.
The `BrazeUI` library of the Swift SDK provides two default view controller contexts: navigation or modal. This means you can integrate Content Cards in these contexts by adding a few lines of code to your app or site. Both views offer customization and styling options as described in the [customization guide]({{site.baseurl}}/developer_guide/customization_guides/content_cards/customizing_styles/?tab=ios). You can also create a custom Content Card view controller instead of using the standard Braze one for even more customization options—refer to the [Content Cards UI tutorial](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c2-contentcardsui/) for an example.

{% alert important %}
To handle control variant Content Cards in your custom UI, pass in your [`Braze.ContentCard.Control`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/contentcard/control(_:)) object, then call the `logImpression` method as you would with any other Content Card type. The object will implicitly log a control impression to inform our analytics of when a user would have seen the control card.
{% endalert %}

## Navigation context

Expand Down Expand Up @@ -121,4 +123,4 @@ For more details, refer to the [`Context` class documentation](https://braze-inc
The Swift SDK does not provide animated GIF support by default. Support can be added by wrapping a third party or your own view in an instance of `GIFViewProvider`.

For more details on GIF support, refer to this [tutorial](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c3-gif-support).
{% endalert %}
{% endalert %}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ page_order: 1

> Learn how to customize your Content Cards for Apple's tvOS platform.
{% alert important %}
Keep in mind, you'll need to implement your own custom UI since Content Cards are supported via headless UI using the Swift SDK—which does not include any default UI or views for tvOS.
{% endalert %}

## Setting up your tvOS app

### Step 1: Create a new iOS app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ page_order: 0

> Learn how to customize your in-app messages for Apple's tvOS platform.
{% alert important %}
Keep in mind, you'll need to implement your own custom UI since in-app messaging is supported via headless UI using the Swift SDK—which does not include any default UI or views for tvOS.
{% endalert %}

## Setting up your tvOS app

### Step 1: Create a new iOS app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The Swift SDK provides a configuration-only approach to automate the processing
To enable the automatic push integration, set the `automation` property of the `push` configuration to `true`:

{% tabs %}
{% tab swift %}
{% tab Swift %}
```swift
let configuration = Braze.Configuration(apiKey: "{YOUR-BRAZE-API-KEY}", endpoint: "{YOUR-BRAZE-API-ENDPOINT}")
configuration.push.automation = true
Expand Down Expand Up @@ -85,7 +85,7 @@ The SDK must be initialized on the main thread to enable push notification autom
For more granular control, each automation step can be enabled or disabled individually:
{% tabs %}
{% tab swift %}
{% tab Swift %}
```swift
// Enable all automations and disable the automatic notification authorization request at launch.
Expand Down Expand Up @@ -130,7 +130,7 @@ The following code sample includes integration for provisional push authenticati
{% endalert %}
{% tabs %}
{% tab swift %}
{% tab Swift %}
```swift
application.registerForRemoteNotifications()
Expand Down Expand Up @@ -178,7 +178,7 @@ You must assign your delegate object using `center.delegate = self` synchronousl
Once APNs registration is complete, pass the resulting `deviceToken` to Braze to enable for push notifications for the user.
{% tabs %}
{% tab swift %}
{% tab Swift %}
Add the following code to your app's `application(_:didRegisterForRemoteNotificationsWithDeviceToken:)` method:
Expand Down Expand Up @@ -206,10 +206,11 @@ The `application:didRegisterForRemoteNotificationsWithDeviceToken:` delegate met
Next, pass the received push notifications along to Braze. This step is necessary for logging push analytics and link handling. Ensure that you call all push integration code in your application's main thread.
{% tabs %}
{% tab swift %}
#### Default push handling
Add the following code to your app's `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` method:
{% tabs %}
{% tab Swift %}
To enable Braze's default push handling, add the following code to your app's `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` method:
```swift
if let braze = AppDelegate.braze, braze.notifications.handleBackgroundNotification(
Expand All @@ -221,7 +222,7 @@ if let braze = AppDelegate.braze, braze.notifications.handleBackgroundNotificati
completionHandler(.noData)
```

Next, add the following code to your app's `userNotificationCenter(_:didReceive:withCompletionHandler:)` method:
Next, add the following to your app's `userNotificationCenter(_:didReceive:withCompletionHandler:)` method:

```swift
if let braze = AppDelegate.braze, braze.notifications.handleUserNotification(
Expand All @@ -232,29 +233,10 @@ if let braze = AppDelegate.braze, braze.notifications.handleUserNotification(
}
completionHandler()
```

**Foreground push handling**

To display a push notification while the app is in the foreground, implement `userNotificationCenter(_:willPresent:withCompletionHandler:)`:

```swift
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if #available(iOS 14.0, *) {
completionHandler([.list, .banner])
} else {
completionHandler([.alert])
}
}
```

If the foreground notification is clicked, the push delegate `userNotificationCenter(_:didReceive:withCompletionHandler:)` will be called, and Braze will log a push click event.

{% endtab %}
{% tab OBJECTIVE-C %}

Add the following code to your application's `application:didReceiveRemoteNotification:fetchCompletionHandler:` method:
{% tab OBJECTIVE-C %}
To enable Braze's default push handling, add the following code to your application's `application:didReceiveRemoteNotification:fetchCompletionHandler:` method:

```objc
BOOL processedByBraze = AppDelegate.braze != nil && [AppDelegate.braze.notifications handleBackgroundNotificationWithUserInfo:userInfo
Expand All @@ -277,25 +259,56 @@ if (processedByBraze) {
completionHandler();
```
{% endtab %}
{% endtabs %}

**Foreground push handling**
#### Foreground push handling

To display a push notification while the app is in the foreground, implement `userNotificationCenter:willPresentNotification:withCompletionHandler:`:
{% tabs %}
{% tab Swift %}
To enable foreground push notifications and let Braze recognize them when they're received, implement `UNUserNotificationCenter.userNotificationCenter(_:willPresent:withCompletionHandler:)`. If a user taps your foreground notification, the `userNotificationCenter(_:didReceive:withCompletionHandler:)` push delegate will be called and Braze will log the push click event.

```swift
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions
) -> Void) {
if let braze = AppDelegate.braze {
// Forward notification payload to Braze for processing.
braze.notifications.handleForegroundNotification(notification: notification)
}

// Configure application's foreground notification display options.
if #available(iOS 14.0, *) {
completionHandler([.list, .banner])
} else {
completionHandler([.alert])
}
}
```
{% endtab %}

{% tab OBJECTIVE-C %}
To enable foreground push notifications and let Braze recognize them when they're received, implement `userNotificationCenter:willPresentNotification:withCompletionHandler:`. If a user taps your foreground notification, the `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` push delegate will be called and Braze will log the push click event.

```objc
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
if (AppDelegate.braze != nil) {
// Forward notification payload to Braze for processing.
[AppDelegate.braze.notifications handleForegroundNotificationWithNotification:notification];
}

// Configure application's foreground notification display options.
if (@available(iOS 14.0, *)) {
completionHandler(UNNotificationPresentationOptionList | UNNotificationPresentationOptionBanner);
} else {
completionHandler(UNNotificationPresentationOptionAlert);
}
}
```

If the foreground notification is clicked, the push delegate `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` will be called, and Braze will log a push click event.

{% endtab %}
{% endtabs %}

Expand All @@ -305,32 +318,45 @@ Deep linking from a push into the app is automatically handled via our standard

## Subscribing to push notifications updates

To access the push notification payloads processed by Braze, use the [`Braze.Notifications.subscribeToUpdates(_:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/notifications-swift.class/subscribetoupdates(_:)/) method.

{% tabs %}
{% tab swift %}
{% tab Swift %}
To access the push notification payloads processed by Braze, use the [`Braze.Notifications.subscribeToUpdates(payloadTypes:_:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/notifications-swift.class/subscribetoupdates(payloadtypes:_:)/) method.

You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, push received events, or both.

{% alert important %}
Keep in mind, push received events will only trigger for foreground notifications and `content-available` background notifications. It will not trigger for notifications received while terminated or for background notifications without the `content-available` field.
{% endalert %}

```swift
// This subscription is maintained through a Braze cancellable, which will observe for changes until the subscription is cancelled.
// You must keep a strong reference to the cancellable to keep the subscription active.
// The subscription is canceled either when the cancellable is deinitialized or when you call its `.cancel()` method.
let cancellable = AppDelegate.braze?.notifications.subscribeToUpdates { payload in
let cancellable = AppDelegate.braze?.notifications.subscribeToUpdates(payloadTypes: [.open, .received]) { payload in
print("Braze processed notification with title '\(payload.title)' and body '\(payload.body)'")
}
```

{% endtab %}

{% tab OBJECTIVE-C %}
To access the push notification payloads processed by Braze, use the [`Braze.Notifications.subscribeToUpdates(payloadTypes:_:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/notifications-swift.class/subscribetoupdates(payloadtypes:_:)/) method.

You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, push received events, or both.

{% alert important %}
Keep in mind, push received events will only trigger for foreground notifications and `content-available` background notifications. It will not trigger for notifications received while terminated or for background notifications without the `content-available` field.
{% endalert %}

```objc
BRZCancellable *cancellable = [notifications subscribeToUpdatesWithInternalNotifications:NO update:^(BRZNotificationsPayload * _Nonnull payload) {
NSInteger filtersValue = BRZNotificationsPayloadTypeFilter.opened.rawValue | BRZNotificationsPayloadTypeFilter.received.rawValue;
BRZNotificationsPayloadTypeFilter *filters = [[BRZNotificationsPayloadTypeFilter alloc] initWithRawValue: filtersValue];
BRZCancellable *cancellable = [notifications subscribeToUpdatesWithPayloadTypes:filters update:^(BRZNotificationsPayload * _Nonnull payload) {
NSLog(@"Braze processed notification with title '%@' and body '%@'", payload.title, payload.body);
}];
```
{% endtab %}
{% endtabs %}
{% endtabs %}
{% alert note %}
When using the automatic push integration, `subscribeToUpdates(_:)` is the only way to be notified of remote notifications processed by Braze. The `UIAppDelegate` and `UNUserNotificationCenterDelegate` system methods are not called when the notification is automatically processed by Braze.
{% endalert %}
Expand All @@ -348,6 +374,8 @@ If you'd like to test in-app and push notifications via the command line, you ca
If you are using the [older navigation]({{site.baseurl}}/navigation), these pages are in a different location: <br>- **API Keys** is located at **Developer Console** > **API Settings** <br>- **Search Users** is located at **Users** > **User Search**
{% endalert %}
In the following example, the `US-01` instance is being used. If you're not on this instance, refer to our [API documentation][66] to see which endpoint to make requests to.
```bash
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {YOUR_API_KEY}" -d '{
"external_user_ids":["YOUR_EXTERNAL_USER_ID"],
Expand All @@ -361,7 +389,6 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {YOUR
}
}' https://rest.iad-01.braze.com/messages/send
```
The preceding example is for customers on the `US-01` instance. If you are not on this instance, refer to our [API documentation][66] to see which endpoint to make requests to.

## Push primers {#push-primers}

Expand Down
Loading

0 comments on commit 1b0778a

Please sign in to comment.