このページはAIにより自動翻訳されており、不正確な内容が含まれている可能性があります。翻訳の誤りを報告するには、ページ右側の目次の下にあるフィードバックをご利用ください。

警告
AppboyKit(Objective-C SDKとも呼ばれます)はもはやサポートされておらず、Swift SDK. 新しい機能、バグ修正、セキュリティー更新s、またはテクニカルサポートを受けません。ただし、メッセージングと分析は通常どおり機能し続けます。詳しくは、新しいBrazeの概要SDK]を参照してください。
iOS向けにカスタム属性を設定する
Brazeには、ユーザーに属性を割り当てるメソッドが用意されています。ダッシュボードでこれらの属性に基づいて、ユーザーのフィルター処理やセグメント化を行うことができます。
実装前に、カスタムイベント、カスタム属性、および購入イベントによって提供されるセグメンテーションオプションの例をベストプラクティスで確認し、イベント命名規則に関する注意事項も必ず確認してください。
デフォルトユーザー属性の割り当て
ユーザー属性を割り当てるには、共有ABKUserオブジェクトの適切なフィールドを設定する必要があります。
以下は、名属性を設定する例です。
1
| [Appboy sharedInstance].user.firstName = @"first_name";
|
1
| Appboy.sharedInstance()?.user.firstName = "first_name"
|
以下の属性は、ABKUserオブジェクトに設定する必要があります。
firstName
lastName
email
dateOfBirth
country
language
homeCity
phone
userID
gender
カスタムユーザー属性の割り当て
デフォルトのユーザー属性だけでなく、Brazeではさまざまなデータタイプを使用してカスタム属性を定義することもできます。セグメンテーションオプションの詳細と、これらの各属性がどのように影響するかについては、ユーザーデータ収集を参照してください。
文字列値のカスタム属性
1
| [[Appboy sharedInstance].user setCustomAttributeWithKey:@"your_attribute_key" andStringValue:"your_attribute_value"];
|
1
| Appboy.sharedInstance()?.user.setCustomAttributeWithKey("your_attribute_key", andStringValue: "your_attribute_value")
|
整数値のカスタム属性
1
| [[Appboy sharedInstance].user setCustomAttributeWithKey:@"your_attribute_key" andIntegerValue:yourIntegerValue];
|
1
| Appboy.sharedInstance()?.user.setCustomAttributeWithKey("your_attribute_key", andIntegerValue: yourIntegerValue)
|
double値のカスタム属性
Brazeはデータベース内でfloatとdoubleの値を同じように扱います。
1
| [[Appboy sharedInstance].user setCustomAttributeWithKey:@"your_attribute_key" andDoubleValue:yourDoubleValue];
|
1
| Appboy.sharedInstance()?.user.setCustomAttributeWithKey("your_attribute_key", andDoubleValue: yourDoubleValue)
|
ブール値のカスタム属性
1
| [[Appboy sharedInstance].user setCustomAttributeWithKey:@"your_attribute_key" andBOOLValue:yourBOOLValue];
|
1
| Appboy.sharedInstance()?.user.setCustomAttributeWithKey("your_attribute_key", andBOOLValue: yourBoolValue)
|
日付値のカスタム属性
このメソッドでBrazeに渡す日付は、ISO 8601形式(例:2013-07-16T19:20:30+01:00)またはyyyy-MM-dd'T'HH:mm:ss:SSSZ形式(2016-12-14T13:32:31.601-0800)である必要があります。
1
| [[Appboy sharedInstance].user setCustomAttributeWithKey:@"your_attribute_key" andDateValue:yourDateValue];
|
1
| Appboy.sharedInstance()?.user.setCustomAttributeWithKey("your_attribute_key", andDateValue:yourDateValue)
|
配列値のカスタム属性
配列の要素数のデフォルトおよび最大値は500です。最大配列数はBrazeダッシュボードのデータ設定 > カスタム属性で更新できます。最大要素数を超える配列は、最大要素数に切り詰められます。
1
2
3
4
5
6
7
8
| // Setting a custom attribute with an array value
[[Appboy sharedInstance].user setCustomAttributeArrayWithKey:@"array_name" array:@[@"value1", @"value2"]];
// Adding to a custom attribute with an array value
[[Appboy sharedInstance].user addToCustomAttributeArrayWithKey:@"array_name" value:@"value3"];
// Removing a value from an array type custom attribute
[[Appboy sharedInstance].user removeFromCustomAttributeArrayWithKey:@"array_name" value:@"value2"];
// Removing an entire array and key
[[Appboy sharedInstance].user setCustomAttributeArrayWithKey:@"array_name" array:nil];
|
1
2
3
4
5
6
| // Setting a custom attribute with an array value
Appboy.sharedInstance()?.user.setCustomAttributeArrayWithKey("array_name", array: ["value1", "value2"])
// Adding to a custom attribute with an array value
Appboy.sharedInstance()?.user.addToCustomAttributeArrayWithKey("array_name", value: "value3")
// Removing a value from an array type custom attribute
Appboy.sharedInstance()?.user.removeFromCustomAttributeArrayWithKey("array_name", value: "value2")
|
カスタム属性の設定解除
カスタム属性は、以下のメソッドを使用して設定解除することもできます。
1
| [[Appboy sharedInstance].user unsetCustomAttributeWithKey:@"your_attribute_key"];
|
1
| Appboy.sharedInstance()?.user.unsetCustomAttributeWithKey("your_attribute_key")
|
カスタム属性の増減
このコードは、カスタム属性をインクリメントする例です。カスタム属性の値は、任意の正または負の整数値やlong値でインクリメントできます。
1
| [[Appboy sharedInstance].user incrementCustomUserAttribute:@"your_attribute_key" by:incrementIntegerValue];
|
1
| Appboy.sharedInstance()?.user.incrementCustomUserAttribute("your_attribute_key", by: incrementIntegerValue)
|
REST APIによるカスタム属性の設定
REST APIを使用してユーザー属性を設定することもできます。詳細については、ユーザーAPIドキュメントを参照してください。
カスタム属性値の制限
カスタム属性値の最大長は255文字です。それを超える値は切り詰められます。
ユーザー購読の設定
ユーザーの購読(メールまたはプッシュ)を設定するには、それぞれsetEmailNotificationSubscriptionTypeまたはsetPushNotificationSubscriptionType関数を呼び出します。これらの関数はどちらも、引数として列挙型ABKNotificationSubscriptionTypeを受け取ります。この型には3つの異なるステータスがあります。
| 購読ステータス |
定義 |
ABKOptedin |
購読済みで、明示的にオプトインしている |
ABKSubscribed |
購読済みだが、明示的にはオプトインしていない |
ABKUnsubscribed |
購読解除済み、または明示的にオプトアウトしている |
アプリにプッシュ通知の送信を許可したユーザーは、iOSでは明示的なオプトインが必要なため、デフォルトでABKOptedinステータスに設定されます。
有効なメールアドレスを受信すると、ユーザーは自動的にABKSubscribedに設定されます。ただし、明示的なオプトインプロセスを確立し、ユーザーから明示的な同意を得た時点でこの値をOptedInに設定することを推奨します。詳細については、ユーザー購読の管理を参照してください。
メール購読の設定
1
| [[Appboy sharedInstance].user setEmailNotificationSubscriptionType: ABKNotificationSubscriptionType]
|
1
| Appboy.sharedInstance()?.user.setEmailNotificationSubscriptionType(ABKNotificationSubscriptionType)
|
プッシュ通知購読の設定
1
| [[Appboy sharedInstance].user setPushNotificationSubscriptionType: ABKNotificationSubscriptionType]
|
1
| Appboy.sharedInstance()?.user.setPushNotificationSubscriptionType(ABKNotificationSubscriptionType)
|
詳細については、ユーザー購読の管理を参照してください。