Skip to content

Commit

Permalink
Merge pull request #7909 from braze-inc/develop
Browse files Browse the repository at this point in the history
Leftover deploy - August 15, 2024
  • Loading branch information
rachel-feinberg authored Aug 15, 2024
2 parents e4e2674 + f7cd2d1 commit b209e78
Show file tree
Hide file tree
Showing 47 changed files with 638 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ As soon as you upload your credentials to Braze, you can start sending push noti

- [Verify your sender ID](#step-2-verify-your-sender-id)
- [Verify your permissions](#step-5-verify-permissions-optional)
- Review push notification errors in your [message activity log](https://www.braze.com/docs/user_guide/administrative/app_settings/message_activity_log_tab/)
- Review push notification errors in your [message activity log]({{site.baseurl}}/user_guide/administrative/app_settings/message_activity_log_tab/)

If you're still having trouble, see [Reverting your credentials](#reverting-your-credentials).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ All string values such as first name, last name, country, and home city are limi

### Custom user attributes

In addition to our predefined user attribute methods, Braze also provides [custom attributes](https://www.braze.com/docs/user_guide/data_and_analytics/custom_data/custom_attributes/#custom-attribute-data-types) to track data from your applications.
In addition to our predefined user attribute methods, Braze also provides [custom attributes]({{site.baseurl}}/user_guide/data_and_analytics/custom_data/custom_attributes/#custom-attribute-data-types) to track data from your applications.

```javascript
Braze.setCustomUserAttribute("attribute_key", "attribute_value", function(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
nav_title: Adding the JavaScript Interface
article_title: Adding the Braze JavaScript Interface to WebViews for Swift
platform: Swift
page_order: 5
description: "This reference article shows how to add the Braze JavaScript Interface to WebViews."

---

# Adding the Braze JavaScript interface to WebViews

> Learn how to add the Braze JavaScript interface to your iOS app, so you can leverage Braze in custom WebViews. After you add the interface, you'll be able to use the API for [HTML in-app messages]({{site.baseurl}}/user_guide/message_building_by_channel/in-app_messages/customize/#custom-html-messages) in your custom WebViews.
## About the interface

The Braze [`ScriptMessageHandler`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/webviewbridge/scriptmessagehandler) is responsible for:

1. Injecting the Braze Javascript bridge into your WebView, as outlined in [HTML in-app messages]({{site.baseurl}}/user_guide/message_building_by_channel/in-app_messages/customize/#custom-html-messages).
2. Passing the bridge methods received from your WebView to the [Braze Swift SDK](https://github.com/braze-inc/braze-swift-sdk).

## Adding the interface to a WebView

First, add the [`ScriptMessageHandler`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/webviewbridge/scriptmessagehandler) from `WebViewBridge` to your app.

```swift
let scriptMessageHandler = Braze.WebViewBridge.ScriptMessageHandler(braze: braze)
```

Add the initialized `scriptMessageHandler` to a WkWebView's `userContentController`.

```swift
configuration.userContentController.add(
scriptMessageHandler,
name: Braze.WebViewBridge.ScriptMessageHandler.name
)
```

Then create the WebView using your configuration.

```swift
let webView = WKWebView(frame: .zero, configuration: configuration)
```

When you're finished, your code should be similar to the following:

```swift
// Create the script message handler using your initialized Braze instance.
let scriptMessageHandler = Braze.WebViewBridge.ScriptMessageHandler(braze: braze)

// Create a web view configuration and setup the script message handler.
let configuration = WKWebViewConfiguration()
configuration.userContentController.addUserScript(
Braze.WebViewBridge.ScriptMessageHandler.script
)
configuration.userContentController.add(
scriptMessageHandler,
name: Braze.WebViewBridge.ScriptMessageHandler.name
)

// Create the webview using the configuration
let webView = WKWebView(frame: .zero, configuration: configuration)
```

## Example: Logging a custom event

In the following example, `BrazeBridge` is used to log a custom event from existing web content to the Braze Swift SDK.

```javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Logging data via BrazeBridge Example</title>
<script>
function logData(data) {
window.brazeBridge.logCustomEvent(data);
}
</script>
</head>

<body>
<input
type="button"
value="Click to log a custom Event 'completed_level'"
onclick="logData('completed_level')"
/>
</body>
</html>
```
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ braze.getUser().setDateOfBirth(2000, 12, 25);

## Assigning custom user attributes

In addition to our predefined user attribute methods, Braze also provides [custom attributes](https://www.braze.com/docs/user_guide/data_and_analytics/custom_data/custom_attributes/#custom-attribute-data-types) to track data from your applications.
In addition to our predefined user attribute methods, Braze also provides [custom attributes]({{site.baseurl}}/user_guide/data_and_analytics/custom_data/custom_attributes/#custom-attribute-data-types) to track data from your applications.

Full method specifications for custom attributes can be found here within the [JSDocs][1].

Expand Down
189 changes: 139 additions & 50 deletions _docs/_developer_guide/platform_wide/feature_flags/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,141 +283,230 @@ If a feature flag is not enabled, or a property you reference does not exist, th
{% tab JavaScript %}

```javascript
// Feature flag instance
// Returns the Feature Flag instance
const featureFlag = braze.getFeatureFlag("expanded_user_profile");
// String properties

// Returns the String property
const stringProperty = featureFlag.getStringProperty("color");
// Boolean properties

// Returns the boolean property
const booleanProperty = featureFlag.getBooleanProperty("expanded");
// Number properties

// Returns the number property
const numberProperty = featureFlag.getNumberProperty("height");
// returns the property as a number in milliseconds

// Returns the Unix UTC millisecond timestamp property as a number
const timestampProperty = featureFlag.getTimestampProperty("account_start");
// returns the property as a string of the image URL

// Returns the image property as a String of the image URL
const imageProperty = featureFlag.getImageProperty("homepage_icon");
// returns the JSON property as as JSON object

// Returns the JSON object property as a FeatureFlagJsonPropertyValue
const jsonProperty = featureFlag.getJsonProperty("footer_settings");
```

{% endtab %}
{% tab Swift %}

```swift
// Feature flag instance
// Returns the Feature Flag instance
let featureFlag: FeatureFlag = braze.featureFlags.featureFlag(id: "expanded_user_profile")
// String properties

// Returns the String property
let stringProperty: String? = featureFlag.stringProperty(key: "color")
// Boolean properties

// Returns the boolean property
let booleanProperty: Bool? = featureFlag.boolProperty(key: "expanded")
// Number properties

// Returns the number property as a double
let numberProperty: Double? = featureFlag.numberProperty(key: "height")
// returns the property as a TimeInterval in milliseconds

// Returns the Unix UTC millisecond timestamp property as an integer
let timestampProperty : Int? = featureFlag.timestampProperty(key: "account_start")
// returns the property as a string of the image URL

// Returns the image property as a String of the image URL
let imageProperty : String? = featureFlag.imageProperty(key: "homepage_icon")
// returns the property as a [String: Any] dictionary

// Returns the JSON object property as a [String: Any] dictionary
let jsonObjectProperty : [String: Any]? = featureFlag.jsonObjectProperty(key: "footer_settings")
```

{% endtab %}
{% tab Java %}

```java
// Feature flag instance
// Returns the Feature Flag instance
FeatureFlag featureFlag = braze.getFeatureFlag("expanded_user_profile");
// String properties

// Returns the String property
String stringProperty = featureFlag.getStringProperty("color");
// Boolean properties

// Returns the boolean property
Boolean booleanProperty = featureFlag.getBooleanProperty("expanded");
// Number properties

// Returns the number property
Number numberProperty = featureFlag.getNumberProperty("height");
// returns the property as a nullable long in milliseconds

// Returns the Unix UTC millisecond timestamp property as a long
Long timestampProperty = featureFlag.getTimestampProperty("account_start");
// returns the property as a string of the image URL

// Returns the image property as a String of the image URL
String imageProperty = featureFlag.getImageProperty("homepage_icon");
// returns the property as a JSON Object

// Returns the JSON object property as a JSONObject
JSONObject jsonObjectProperty = featureFlag.getJSONProperty("footer_settings");
```

{% endtab %}
{% tab Kotlin %}

```kotlin
// feature flag instance
// Returns the Feature Flag instance
val featureFlag = braze.getFeatureFlag("expanded_user_profile")
// string properties

// Returns the String property
val stringProperty: String? = featureFlag.getStringProperty("color")
// boolean properties

// Returns the boolean property
val booleanProperty: Boolean? = featureFlag.getBooleanProperty("expanded")
// number properties

// Returns the number property
val numberProperty: Number? = featureFlag.getNumberProperty("height")
// returns the property as a nullable long in milliseconds

// Returns the Unix UTC millisecond timestamp property as a long
val timestampProperty: Long? = featureFlag.getTimestampProperty("account_start")
// returns the property as a string of the image URL
val String imageProperty: String? = featureFlag.getImageProperty("homepage_icon")
// returns the property as a JSON Object

// Returns the image property as a String of the image URL
val imageProperty: String? = featureFlag.getImageProperty("homepage_icon")

// Returns the JSON object property as a JSONObject
val jsonObjectProperty: JSONObject? = featureFlag.getJSONProperty("footer_settings")
```

{% endtab %}
{% tab React Native %}

```javascript
// String properties
// Returns the String property
const stringProperty = await Braze.getFeatureFlagStringProperty("expanded_user_profile", "color");
// Boolean properties

// Returns the boolean property
const booleanProperty = await Braze.getFeatureFlagBooleanProperty("expanded_user_profile", "expanded");
// Number properties

// Returns the number property
const numberProperty = await Braze.getFeatureFlagNumberProperty("expanded_user_profile", "height");

// Returns the Unix UTC millisecond timestamp property as a number
const timestampProperty = await Braze.getFeatureFlagTimestampProperty("expanded_user_profile", "account_start");

// Returns the image property as a String of the image URL
const imageProperty = await Braze.getFeatureFlagImageProperty("expanded_user_profile", "homepage_icon");

// Returns the JSON object property as an object
const jsonObjectProperty = await Braze.getFeatureFlagJSONProperty("expanded_user_profile", "footer_settings");
```

{% endtab %}
{% tab Unity %}

```csharp
// Feature flag instance
// Returns the Feature Flag instance
var featureFlag = Appboy.AppboyBinding.GetFeatureFlag("expanded_user_profile");
// String properties
var stringProperty = featureFlag.getStringProperty("color");
// Boolean properties
var booleanProperty = featureFlag.getBooleanProperty("expanded");
// Number property as integer
var integerProperty = featureFlag.getIntegerProperty("height");
// Number property as double
var doubleProperty = featureFlag.getDoubleProperty("height");

// Returns the String property
var stringProperty = featureFlag.GetStringProperty("color");

// Returns the boolean property
var booleanProperty = featureFlag.GetBooleanProperty("expanded");

// Returns the number property as an integer
var integerProperty = featureFlag.GetIntegerProperty("height");

// Returns the number property as a double
var doubleProperty = featureFlag.GetDoubleProperty("height");

// Returns the Unix UTC millisecond timestamp property as a long
var timestampProperty = featureFlag.GetTimestampProperty("account_start");

// Returns the image property as a String of the image URL
var imageProperty = featureFlag.GetImageProperty("homepage_icon");

// Returns the JSON object property as a JSONObject
var jsonObjectProperty = featureFlag.GetJSONProperty("footer_settings");
```

{% endtab %}
{% tab Cordova %}

```javascript
// String properties
// Returns the String property
const stringProperty = await BrazePlugin.getFeatureFlagStringProperty("expanded_user_profile", "color");
// Boolean properties

// Returns the boolean property
const booleanProperty = await BrazePlugin.getFeatureFlagBooleanProperty("expanded_user_profile", "expanded");
// Number properties

// Returns the number property
const numberProperty = await BrazePlugin.getFeatureFlagNumberProperty("expanded_user_profile", "height");

// Returns the Unix UTC millisecond timestamp property as a number
const timestampProperty = await BrazePlugin.getFeatureFlagTimestampProperty("expanded_user_profile", "account_start");

// Returns the image property as a String of the image URL
const imageProperty = await BrazePlugin.getFeatureFlagImageProperty("expanded_user_profile", "homepage_icon");

// Returns the JSON object property as an object
const jsonObjectProperty = await BrazePlugin.getFeatureFlagJSONProperty("expanded_user_profile", "footer_settings");
```

{% endtab %}
{% tab Flutter %}

```dart
// Returns the Feature Flag instance
BrazeFeatureFlag featureFlag = await braze.getFeatureFlagByID("expanded_user_profile");
// String properties
// Returns the String property
var stringProperty = featureFlag.getStringProperty("color");
// Boolean properties
// Returns the boolean property
var booleanProperty = featureFlag.getBooleanProperty("expanded");
// Number properties
// Returns the number property
var numberProperty = featureFlag.getNumberProperty("height");
// Returns the Unix UTC millisecond timestamp property as an integer
var timestampProperty = featureFlag.getTimestampProperty("account_start");
// Returns the image property as a String of the image URL
var imageProperty = featureFlag.getImageProperty("homepage_icon");
// Returns the JSON object property as a Map<String, dynamic> collection
var jsonObjectProperty = featureFlag.getJSONProperty("footer_settings");
```

{% endtab %}
{% tab Roku %}

```brightscript
' String properties
' Returns the String property
color = featureFlag.getStringProperty("color")
' Boolean properties
' Returns the boolean property
expanded = featureFlag.getBooleanProperty("expanded")
' Number properties
' Returns the number property
height = featureFlag.getNumberProperty("height")
' Returns the Unix UTC millisecond timestamp property
account_start = featureFlag.getTimestampProperty("account_start")
' Returns the image property as a String of the image URL
homepage_icon = featureFlag.getImageProperty("homepage_icon")
' Returns the JSON object property
footer_settings = featureFlag.getJSONProperty("footer_settings")
```

{% endtab %}
{% endtabs %}

Expand Down
Loading

0 comments on commit b209e78

Please sign in to comment.