分支 io 添加自定义数据
Branch io adding custom data
生成分支io链接时如何添加自定义数据?
async generateBranchUrl(cb) {
const userId = this.props.currentUser.objectId;
const userEmail = this.props.currentUser.email;
const branchUniversalObject = await branch.createBranchUniversalObject(userId);
const linkProperties = { feature: 'userReferral', tags: [userId, userEmail] };
branchUniversalObject.generateShortUrl(linkProperties, {})
.then((res) => {
cb(res);
})
.catch((err) => {
Alert.alert('Failed to generate link');
});
}
假设您正在与 React Native SDK 集成,您将向 contentMetadata 下的 branchUniversalObject 添加任何自定义数据,如下所示:
let branchUniversalObject = await branch.createBranchUniversalObject('canonicalIdentifier', {
locallyIndex: true,
title: 'Cool Content!',
contentDescription: 'Cool Content Description'}),
contentMetadata: {
ratingAverage: 4.2,
customMetadata: {
prop1: 'test',
prop2: 'abc'
}
}
})
要读取自定义数据,只需传递您定义的键即可从 params 对象中获取数据。
生成分支io链接时如何添加自定义数据?
async generateBranchUrl(cb) {
const userId = this.props.currentUser.objectId;
const userEmail = this.props.currentUser.email;
const branchUniversalObject = await branch.createBranchUniversalObject(userId);
const linkProperties = { feature: 'userReferral', tags: [userId, userEmail] };
branchUniversalObject.generateShortUrl(linkProperties, {})
.then((res) => {
cb(res);
})
.catch((err) => {
Alert.alert('Failed to generate link');
});
}
假设您正在与 React Native SDK 集成,您将向 contentMetadata 下的 branchUniversalObject 添加任何自定义数据,如下所示:
let branchUniversalObject = await branch.createBranchUniversalObject('canonicalIdentifier', {
locallyIndex: true,
title: 'Cool Content!',
contentDescription: 'Cool Content Description'}),
contentMetadata: {
ratingAverage: 4.2,
customMetadata: {
prop1: 'test',
prop2: 'abc'
}
}
})
要读取自定义数据,只需传递您定义的键即可从 params 对象中获取数据。