Skip to content

Brazeアクションのディープリンク

Brazeアクションを使用すると、「ディープリンク」を使ってネイティブSDKの機能を実行できます。

Brazeダッシュボードには、いくつかの標準的なクリック時アクション(プッシュ通知の権限をリクエスト、カスタムイベントをログに記録、カスタム属性をログに記録)が含まれており、アプリ内メッセージやContent Cardsで使用できます。

その他のすべてのアクション、または複数のアクションを組み合わせる場合は、このガイドを使用して独自のBrazeアクションディープリンクを構築してください。

SDKサポート

brazeActions:// ディープリンクスキームは、アプリ内メッセージやContent Cards内にディープリンクやリダイレクトオプションがあれば、どこでも使用できます。

HTMLアプリ内メッセージの場合、HTMLメッセージタイプではディープリンクはサポートされていないため、代わりにJavascript Bridgeを使用してください。

スキーマ

複数のアクションの stepscontainer アクションタイプに含めることができます。container を含まない単一のステップも有効です。

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

個々の step には、アクションの type とオプションの args 配列が含まれます。

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

URI

BrazeアクションのURIスキームは brazeActions://v1/{base64encodedJsonString} です。

次のJavaScriptは、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, "");
}

対応アクション

タイプ 引数
container 実行する他のアクションの配列
logCustomEvent 1. event name
2. event properties JSON object(オプション)
setEmailNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setPushNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setCustomUserAttribute 1. attribute_name
2. attribute_value
requestPushPermission 該当なし
openLink 1. url
2. openInNewTab(ブール値)
openLinkInWebview url
addToSubscriptionGroup subscriptionGroupId
removeFromSubscriptionGroup subscriptionGroupId
addToCustomAttributeArray 1. attribute_name
2. attribute_value
removeFromCustomAttributeArray 1. attribute_name
2. attribute_value

JSONエンコーダー

JSON文字列を入力すると、結果の brazeActions:// URIが表示されます。または、brazeActions:// URIを入力してJSONをデコードできます。

JSON入力

ディープリンク出力

New Stuff!