Hooks
Hooks
You can configure hooks in the JS SDK to run your code in response to SmartWall's events.
onReady
You can pass a function that will run after the SmartWall is loaded and displayed with your configuration.
Params:
- context
{ access: boolean, isMobile: boolean, error: any }
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onReady: function (context) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('ready', function(context) {
// ... Your hook code
})
onUnlock
You can pass a function that will run after the SmartWall is unlocked by the user.
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onUnlock: function () {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('unlock', function() {
// ... Your hook code
})
onPaymentStart
You can pass a function that will run when the user starts a micro-payment in the SmartWall.
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onPaymentStart: function (data, error) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('paymentStart', function(data, error) {
// ... Your hook code
})
onError
You can pass a function that will run when there's any error on the SmartWall.
Params:
- error
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onError: function (error) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('error', function(error) {
// ... Your hook code
})
onAuthenticated
You can pass a function that will run when the user signs in.
Params:
- userInfo
{name: string, locale: string, access: boolean}
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onAuthenticated: function (userInfo) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('authenticated', function(userInfo) {
// ... Your hook code
})
onSubscribed
You can pass a function that will run when the user subscription is detected.
Params:
- userInfo
{name: string, locale: string, access: boolean}
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onSubscribed: function (userInfo) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('subscribed', function(userInfo) {
// ... Your hook code
})
customUnlock
You can pass a function that will overwrite the unlocking behavior of the SmartWall. This way you can have full control on how the article is unlocked. A token is passed to the hook, you can use it to validate that the unlocking petition is coming from SmartWall.
Params:
- token
string
Example:
// You can setup the hook in the constructor
var smartWallSDK = new SmartWallSDK({
// ... Your other sdk params
onCustomUnlock: function (token) {
// ... Your hook code
}
});
// Or you can set it up with the "on" function
smartWallSDK.on('customUnlock', function(token) {
// ... Your hook code
})