Appearance
Custom Actions
Custom actions are the actions which can be created on the dashboard. This type of action allows you to upload a URL for the action to be presented to the user. In Custom Actions we have predefined functions to pass callback to the iOS app.
How to Pass Callback from Custom Action to iOS
Custom Actions provide a way to communicate between web content and your iOS application:
javascript
var CustomAction = (function () {
function sendAction(obj) {
if (window.webkit && window.webkit.messageHandlers) {
var iOSSDK = window.webkit.messageHandlers.upshot;
iOSSDK.postMessage(obj);
} else if (window.AndroidHandler) {
AndroidHandler.performAction(JSON.stringify(obj));
} else {
window.parent.postMessage(
{
upshotMessage: JSON.stringify(obj),
},
"*"
);
}
}
return {
sendAction: sendAction,
};
})();
Callback Types
Ready Callback
Invoke ready callback means scripts are loaded. In case ready callback is not received, Skip option will be enabled.
javascript
CustomAction.sendAction({
a: "ready",
});
Skip Callback
Invoke skip callback function where user can either skip or choose not to participate. SDK will remove custom action and create skip event.
Example: v value is skip button text or id
javascript
CustomAction.sendAction({
a: "skip",
v: "142861v",
});
Respond Callback
Invoke respond callback when the user click on submit or respond to the activity, SDK will remove custom action with respond event.
Example: v value is respond text
javascript
CustomAction.sendAction({
a: "respond",
v: "142861v",
});
Deeplink Callback
Invoke deeplink callback if you want to pass the data to the application, With this method sdk will do the same.
Example: v deeplink text
javascript
CustomAction.sendAction({
a: "deeplink",
v: "deeplink data",
});
Event Callback
Invoke event callback function, If you want to create custom event.
Example: v event data
javascript
CustomAction.sendAction({
a: "event",
v: {
n: "eventName",
d: { a: 1, b: 2 }, //eventPayload
},
});
How to Fetch a Custom Action
Request a custom action activity using tags:
objective-c
@import Upshot;
// Request custom action activity with specific tag
[[BrandKinesis sharedInstance] setDelegate: self];
[[BrandKinesis sharedInstance] showActivityWithType:BKActivityTypeWebComponent andTag:@"Tag Name"];
swift
import Upshot
// Request custom action activity with specific tag
BrandKinesis.sharedInstance(). delegate = self
BrandKinesis.sharedInstance(). showActivity(with: .webComponent, andTag: "TagName")
How to Create a Custom Action in Dashboard
In Dashboard under GAMIFY section Create custom action and create campaign for that custom action.
Creating Custom Action in Dashboard
To create Custom Action in the Upshot.ai dashboard:
- Navigate to GAMIFY section in the dashboard
- Create Custom Action - Design your Custom Action with questions
- Create Campaign - Set targeting and scheduling for the Custom Action