Page context
Passing contextual information to your app allows you to make your app aware of the page it’s on and the user it’s interacting with. There are many benefits to providing contextual information:
- Provide your app with information about the user so you don’t have to ask them for it again.
- Use the user’s location to connect them to a local sales rep or the support team closest to their time zone or geolocation.
- Provide your app with information about how the user is using your mobile app:
- Have your bot respond to the user in their own language.
iOS
The Orb Mobile SDK for iOS exposes a native NSObject
called OrbConnectionOptions
that you use to set a number of connection properties. The pageContext
property allows you to provide a dictionary of data that will be made available to the bot on the page_open
event.
Here is an example OrbConnectionOptions
object taken from the orb-demo-ios
application:
let connectionOptions = OrbConnectionOptions(
gridUrl: gridUrlField.text!,
appId: appIdField.text!,
integrationId: integrationIdField.text!,
pageContext: [
"platform_version": platformVersion,
"a": 1234,
"data": [
"key1": "value1",
"key2": 123123.3,
"bool": true
]
] as [String: Any?]
)
Android
The Orb Mobile SDK for iOS exposes a native OrbConnectionOptions
class that you use to set the Orb connection properties. The pageContext
property allows you to provide a map of data that will be made available to the bot on the page_open
event.
Here is an example OrbConnectionOptions
object taken from the orb-demo-android
application:
Map<String, Object> pageContext = new HashMap<>();
pageContext.put("platform_version", platformVersion);
pageContext.put("key1", 1235);
Map<String, Object> data = new HashMap<>();
data.put("key1", "value1");
data.put("key2", 12345.9);
data.put("bool", true);
pageContext.put("data", data);
OrbConnectionOptions connectionOptions = new OrbConnectionOptions(
gridUrl,
appId,
integrationId,
pageContext
);
Updated about 2 years ago