Skip to content

Commit

Permalink
Merge pull request #7695 from braze-inc/develop
Browse files Browse the repository at this point in the history
Deploy - July 16, 2024
  • Loading branch information
internetisaiah authored Jul 16, 2024
2 parents a1790bd + 859a4d5 commit 74e5057
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 246 deletions.
64 changes: 7 additions & 57 deletions _docs/_contributing/content_management/cross_referencing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ noindex: true

## Create a cross-reference

When creating a cross-reference, you can either use the in-line method or reference-style method. The in-line method prioritizes clarity, while the reference-style method prioritizes readability.
{% alert important %}
Because Liquid's {% raw %}`{% tab %}`{% endraw %} tag does not support reference-style links, only in-line links are documented below. Existing reference links will continue to work, but are no longer recommended.
{% endalert %}

{% tabs %}
{% tab in-line %}
{% tab Markdown %}
Open the relevant Markdown file, then create your in-line link.

{% subtabs %}
{% subtab Markdown %}

{% raw %}
```markdown
[LINK_TEXT]({{site.baseurl}}/SHORT_URL)
Expand All @@ -44,9 +43,10 @@ Your in-line link should be similar to the following:
Before continuing, [create your SSH token]({{site.baseurl}}/docs/developer_guide/platform_wide/sdk_authentication).
```
{% endraw %}
{% endsubtab %}
{% endtab %}

{% subtab HTML %}
{% tab HTML %}
Open the relevant Markdown file, then create your in-line link.

{% raw %}
```markdown
Expand All @@ -69,55 +69,5 @@ Your in-line link should be similar to the following:
To learn about the different custom attribute data types you can use to segment users, view <a href="/docs/user_guide/data_and_analytics/custom_data/custom_attributes/#custom-attribute-data-types">Custom attribute data types</a>.
```
{% endraw %}
{% endsubtab %}
{% endsubtabs %}

{% endtab %}

{% tab reference-style %}
Open the relevant Markdown file, then create your reference-style link.

```markdown
[LINK_TEXT][REFERENCE_NUMBER]
```

Replace the following:

| Placeholder | Description |
|--------------------|--------------------------------------------------------------------------|
| `LINK_TEXT` | The page title or related action. |
| `REFERENCE_NUMBER` | Assign any positive integer that's not already assigned to another reference-style link on this page. |
{: .reset-td-br-1 .reset-td-br-2}

Your references should be similar to the following:

```markdown
Before continuing, [create your SSH token][2]. When you're finished, see [Step 2: Uploading your token][5].
```

At the bottom of the page, you'll add the related links.

{% raw %}
```markdown
[REFERENCE_NUMBER]: {{site.baseurl}}SHORT_URL
```
{% endraw %}

Replace the following:

| Placeholder | Description |
|--------------------|---------------------------------------------------------|
| `REFERENCE_NUMBER` | The number of the reference you'd like to link to. |
| `SHORT_URL` | The page URL with `https://www.braze.com/docs` removed. |
{: .reset-td-br-1 .reset-td-br-2}

Your links should be similar to the following:

{% raw %}
```markdown
[2]: {{site.baseurl}}/developer_guide/platform_wide/sdk_authentication/
[5]: {{site.baseurl}}/developer_guide/platform_wide/swift#step-2-uploading-your-token
```
{% endraw %}
{% endtab %}
{% endtabs %}
70 changes: 3 additions & 67 deletions _docs/_contributing/content_management/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ braze-docs

### Step 2: Link to the image

When linking to your new image, you can either use in-line or reference-style syntax. In-line syntax prioritizes clarity, while reference-style syntax prioritizes readability.
{% alert important %}
Since Liquid's {% raw %}`{% tab %}`{% endraw %} tag does not support reference-style links, only in-line links are documented below. Existing reference links will continue to work, but are no longer recommended.
{% endalert %}

{% tabs %}
{% tab in-line %}
In your Markdown file, link to your new image using the in-line syntax.

{% raw %}
Expand All @@ -73,58 +73,6 @@ Your in-line image should be similar to the following:
![The form for creating a new pull request on GitHub.]({% image_buster /assets/img/contributing/getting_started/github_pull_request.png %})
```
{% endraw %}
{% endtab %}

{% tab reference-style %}
In your Markdown file, link to your new image using the reference-style syntax.

{% raw %}
```markdown
![ALT_TEXT.][REFERENCE_NUMBER]
```
{% endraw %}

Replace the following:

| Placeholder | Description |
|--------------------|-------------------------------------------------------------------------------------------------------------------------|
| `ALT_TEXT` | The alt text for the image. This is required to make Braze Docs equally accessible for those using screen readers. |
| `REFERENCE_NUMBER` | Assign any positive integer that's not already assigned to another reference-style link on this page. |
{: .reset-td-br-1 .reset-td-br-2}

Your in-line image should be similar to the following:

{% raw %}
```markdown
![The form for creating a new pull request on GitHub.][10]
```
{% endraw %}

At the bottom of the page, add your reference.

{% raw %}
```markdown
[REFERENCE_NUMBER]: {% image_buster /assets/img/DIRECTORY/IMAGE.png %}
```
{% endraw %}

Replace the following:

| Placeholder | Description |
|--------------------|---------------------------------------------------------|
| `REFERENCE_NUMBER` | The number of the reference you'd like to link to. |
| `IMAGE` | The relative path to your image starting from the `img` directory. |
{: .reset-td-br-1 .reset-td-br-2}

Your links should be similar to the following:

{% raw %}
```markdown
[10]: {% image_buster /assets/img/contributing/getting_started/github_pull_request.png %}
```
{% endraw %}
{% endtab %}
{% endtabs %}

### Step 3: Set the image's maximum width (optional)

Expand All @@ -138,23 +86,11 @@ You can set the image's maximum width by appending the following Liquid code to

Replace `NUMBER` with the maximum width you'd like to set as a percentage. Your image link should be similar to the following:

{% tabs %}
{% tab in-line %}
{% raw %}
```markdown
![The form for creating a new pull request on GitHub.]({% image_buster /assets/img/contributing/getting_started/github_pull_request.png %}){: style="max-width:65%;"}
```
{% endraw %}
{% endtab %}

{% tab reference-style %}
{% raw %}
```markdown
![The form for creating a new pull request on GitHub.][10]{: style="max-width:65%;"}
```
{% endraw %}
{% endtab %}
{% endtabs %}

## Updating an image

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,11 +206,10 @@ 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.
#### Default push handling
{% tabs %}
{% tab Swift %}
To enable Braze's default push handling, add the following code to your app's `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` method:
{% tab swift %}
Add the following code to your app's `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` method:
```swift
if let braze = AppDelegate.braze, braze.notifications.handleBackgroundNotification(
Expand All @@ -222,7 +221,7 @@ if let braze = AppDelegate.braze, braze.notifications.handleBackgroundNotificati
completionHandler(.noData)
```

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

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

**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 %}
To enable Braze's default push handling, add the following code to your application's `application:didReceiveRemoteNotification:fetchCompletionHandler:` method:

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 @@ -259,54 +277,25 @@ if (processedByBraze) {
completionHandler();
```
{% endtab %}
{% endtabs %}

#### Foreground push handling

{% 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) {
// Forward notification payload to Braze for processing.
AppDelegate.braze?.notifications.handleForegroundNotification(notification: notification)

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

{% 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.
To display a push notification while the app is in the foreground, implement `userNotificationCenter:willPresentNotification:withCompletionHandler:`:

```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 @@ -316,41 +305,32 @@ 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 %}
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. You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, foreground push received events, or both.
{% tab swift %}

```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(payloadTypes: [.open, .received]) { payload in
let cancellable = AppDelegate.braze?.notifications.subscribeToUpdates { payload in
print("Braze processed notification with title '\(payload.title)' and body '\(payload.body)'")
}
```
{% endtab %}

{% endtab %}
{% tab OBJECTIVE-C %}
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. You can use the `payloadTypes` parameter to specify whether you'd like to subscribe to notifications involving push open events, foreground push received events, or both.

```objc
BRZCancellable *cancellable = [notifications subscribeToUpdates:^(BRZNotificationsPayload * _Nonnull payload) {
BRZCancellable *cancellable = [notifications subscribeToUpdatesWithInternalNotifications:NO update:^(BRZNotificationsPayload * _Nonnull payload) {
NSLog(@"Braze processed notification with title '%@' and body '%@'", payload.title, payload.body);
}];
```
Or, to specify the types of push events you'd like to subscribe to:
```objc
NSInteger filtersValue = BRZNotificationsPayloadTypeFilter.opened.rawValue | BRZNotificationsPayloadTypeFilter.received.rawValue;
BRZNotificationsPayloadTypeFilter *filters = [[BRZNotificationsPayloadTypeFilter alloc] initWithRawValue: filtersValue];
BRZCancellable *cancellable = [notifications subscribeToUpdatesWithPayloadTypes:filters:^(BRZNotificationsPayload * _Nonnull payload) {
NSLog(@"Braze processed notification with title '%@' and body '%@'", payload.title, payload.body);
}];
```
{% endtab %}

{% 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 Down
2 changes: 1 addition & 1 deletion _docs/_developer_guide/platform_wide/sdk_authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ braze.subscribeToSdkAuthenticationFailures((error) => {
// TODO: Optionally log to your error-reporting service
// TODO: Check if the `user_id` within the `error` matches the currently logged-in user
const updated_jwt = await getNewTokenSomehow(error);
appboy.setSdkAuthenticationSignature(updated_jwt);
braze.setSdkAuthenticationSignature(updated_jwt);
});
```
{% endtab %}
Expand Down
Loading

0 comments on commit 74e5057

Please sign in to comment.