Skip to content

Deeplinks d’actions Braze

Les actions Braze vous permettent d’utiliser des « deeplinks » pour exécuter des fonctionnalités natives du SDK.

Le tableau de bord de Braze comprend plusieurs actions au clic standard (demander l’autorisation push, enregistrer un événement personnalisé et enregistrer un attribut personnalisé) qui peuvent être utilisées dans les messages in-app et les Content Cards.

Pour toutes les autres actions, ou pour combiner plusieurs actions, utilisez ce guide pour construire votre propre deeplink d’action Braze.

Prise en charge du SDK

Le schéma de deeplink brazeActions:// peut être utilisé partout où une option de deeplink ou de redirection existe dans les messages in-app et les Content Cards.

Pour les messages in-app au format HTML, utilisez plutôt le pont JavaScript, car les deeplinks ne sont pas pris en charge dans les types de messages HTML.

Schéma

Vous pouvez inclure plusieurs steps d’actions dans un type d’action container. Une seule étape sans container est également valide.

1
2
3
4
{
    "type": "container",
    "steps": []
}

Une step individuelle contient un type d’action et un tableau args facultatif :

1
2
3
4
{
    "type": "logCustomEvent",
    "args": ["event name", {"event": ["properties"]}]
}

URI

Le schéma URI des actions Braze est brazeActions://v1/{base64encodedJsonString}.

Le JavaScript suivant montre comment encoder et décoder la chaîne de caractères JSON :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function decode(encoded) {
    const binary = window.atob(encoded.replace(/-/g, '+').replace(/_/g, '/'));
    let bits8 = new Uint8Array(binary.length);
    for (let i = 0; i < binary.length; i++) {
      bits8[i] = binary.charCodeAt(i);
    }
    const bits16 = new Uint16Array(bits8.buffer);
    return String.fromCharCode(...bits16);
}

/**
 * Returns a url-safe base64 encoded string of the input.
 * Unicode inputs are accepted.
 * Converts a UTF-16 string to UTF-8 to comply with base64 encoding limitations.
 */
function encode(input) {
    // Split the original 16-bit char code into two 8-bit char codes then
    // reconstitute a new string (of double length) using those 8-bit codes
    // into a UTF-8 string.
    const codeUnits = new Uint16Array(input.length);
    for (let i = 0; i < codeUnits.length; i++) {
        codeUnits[i] = input.charCodeAt(i);
    }
    const charCodes = new Uint8Array(codeUnits.buffer);
    let utf8String = "";
    for (let i = 0; i < charCodes.byteLength; i++) {
        utf8String += String.fromCharCode(charCodes[i]);
    }
    return btoa(utf8String).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
}

Actions prises en charge

Type Args
container Un tableau d’autres actions à effectuer
logCustomEvent 1. event name
2. event properties JSON object (facultatif)
setEmailNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setPushNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setCustomUserAttribute 1. attribute_name
2. attribute_value
requestPushPermission S.O.
openLink 1. url
2. openInNewTab (booléen)
openLinkInWebview url
addToSubscriptionGroup subscriptionGroupId
removeFromSubscriptionGroup subscriptionGroupId
addToCustomAttributeArray 1. attribute_name
2. attribute_value
removeFromCustomAttributeArray 1. attribute_name
2. attribute_value

Encodeur JSON

Saisissez une chaîne de caractères JSON pour voir l’URI brazeActions:// résultant. Ou saisissez un URI brazeActions:// pour décoder son JSON.

Entrée JSON

Sortie deeplink

New Stuff!