This is an unofficial sdk for branch.io. See API reference for what you can do with branch here
Features
- Initialize SDK using either
appId
or branchKey
Installation
> npm install branchio-sdk
Usage
const branchio = require('branchio-sdk')
const client = branchio({
appId: <APP_ID>,
key: <BRANCH_IO_KEY>
secret: <BRANCH_IO_SECRET>
})
const { url } = await client.link({
alias: '',
stage: 'new user',
channel: 'facebook',
feature: 'dashboard',
campaign: 'content 123',
tags: [ 'tag1', 'tag2', 'tag3' ],
data: {
'custom_bool': true,
'$og_title': 'Title',
'$og_description': 'Description',
'$og_image_url': 'https://lorempixel.com/400/400'
}
})
Methods
link()
This method is use for creating a deep link. See corresponding docs here
const { url } = await client.link({
alias: '',
stage: 'new user',
channel: 'facebook',
feature: 'dashboard',
campaign: 'content 123',
tags: [ 'tag1', 'tag2', 'tag3' ],
data: {
'custom_bool': true,
'$og_title': 'Title',
'$og_description': 'Description',
'$og_image_url': 'https://lorempixel.com/400/400'
}
})
bulkLinks()
This method allows you to create multiple deep links at a go. See docs
const links = await client.bulkLinks([
{
stage: 'new user',
channel: 'facebook',
feature: 'dashboard',
campaign: 'content 123',
tags: [ 'tag1', 'tag2', 'tag3' ],
data: {
'custom_bool': true,
'$og_title': 'Title',
'$og_description': 'Description',
'$og_image_url': 'https://lorempixel.com/400/400'
}
},
{
stage: 'new user',
channel: 'facebook',
feature: 'dashboard',
campaign: 'content 123',
tags: [ 'tag1', 'tag2', 'tag3' ],
data: {
'custom_bool': true,
'$og_title': 'Title',
'$og_description': 'Description',
'$og_image_url': 'https://lorempixel.com/400/400'
}
}
])
readLink()
This method is for reading details of a deep link. See corresponding docs here
const linkData = await client.readLink('https://example.app.link/0AjuiLcpqF')
updateLink()
This method is for updating details of a deep link
const client = branch({ key: '<BRANCH_IO_KEY', secret: '<BRANCH_IO_SECRET' })
const updateData = await client.updateLink({
deepLink: 'https://example.app.link/ggxaqsx1dR',
data: {
channel: 'twitter',
data: {
name: 'John',
user_id: 2481084010
}
}
})
TODO:
...
Maintainers
Samuel Amoah