Skip to content

Deep links de ações da Braze

As ações da Braze permitem que você use “deep links” para executar a funcionalidade nativa do SDK.

O dashboard da Braze inclui várias ações padrão ao clicar (Solicitar permissão para push, Registrar evento personalizado e Registrar atributo personalizado) que podem ser usadas em mensagens no app e Content Cards.

Para todas as outras ações, ou para combinar várias ações, use este guia para construir seu próprio deep link de Braze Action.

Suporte ao SDK

O esquema de deep link brazeActions:// pode ser usado sempre que houver uma opção de deep link ou redirecionamento nas mensagens no app e nos Content Cards.

Para mensagens no app em HTML, use o Javascript Bridge em vez disso, pois os deep links não são compatíveis com tipos de mensagens HTML.

Esquema

Você pode incluir várias steps de ação em um tipo de ação container. Uma única etapa sem um container também é válida.

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

Um step individual contém um type de ação e um array args opcional:

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

URI

O esquema de URI das Braze Actions é brazeActions://v1/{base64encodedJsonString}.

O JavaScript a seguir mostra como codificar e decodificar a string 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, "");
}

Ações compatíveis

Tipo Args
container Um array de outras ações a serem executadas
logCustomEvent 1. event name
2. event properties JSON object (opcional)
setEmailNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setPushNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setCustomUserAttribute 1. attribute_name
2. attribute_value
requestPushPermission N/D
openLink 1. url
2. openInNewTab (booleano)
openLinkInWebview url
addToSubscriptionGroup subscriptionGroupId
removeFromSubscriptionGroup subscriptionGroupId
addToCustomAttributeArray 1. attribute_name
2. attribute_value
removeFromCustomAttributeArray 1. attribute_name
2. attribute_value

Codificador JSON

Insira uma string JSON para ver o URI brazeActions:// resultante. Ou insira um URI brazeActions:// para decodificar seu JSON.

Entrada JSON

Saída do deep link

New Stuff!