Sandbox Integration
With a sandbox integration, you can pass a configuration flag to test against a sandbox environment. A sandbox environment is part of the Rokt production environment however it does not charge advertisers or generate revenue. It follows a normal offers, bidding, and matching process against your production configuration. As a result it can be used for acceptance testing before deploying to production.
The integration follows exactly the same steps as in previous examples, with an additional rokt.testsession
attribute required to be passed to the execute function.
Overlay Placement Example
To run an overlay placement in the sandbox environment, the list of attributes passed to Rokt needs to be updated to include "rokt.testsession": "true"
. This can be done by updating the code from Step 5 of Launching an Overlay Placement to the following:
Swift
import Rokt_Widget
class OrderConfirmationViewController: UIViewController {
...
// call this function when the placement needs to be shown
func showWidget() {
let attributes = ["email": "j.smith@example.com",
"rokt.testsession": "true",
"firstname": "Jenny",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"]
Rokt.execute(viewName: "RoktExperience", attributes: attributes, onLoad: {
// Optional callback for when the Rokt placement loads
}, onUnLoad: {
// Optional callback for when the Rokt placement unloads
}, onShouldShowLoadingIndicator: {
// Optional callback to show a loading indicator
}, onShouldHideLoadingIndicator: {
// Optional callback to hide a loading indicator
})
}
}
Objective-C
#import <Rokt_Widget/Rokt_Widget-Swift.h>
...
// call this function when placement needs to be shown
- (void)showWidget {
NSDictionary *attributes = @{
@"email" : @"j.smith@example.com",
@"rokt.testsession" : @"true",
@"firstname": @"Jenny",
@"lastname": @"Smith",
@"mobile": @"(555)867-5309",
@"postcode": @"90210",
@"country": @"US"
};
[Rokt executeWithViewName:@"RoktExperience"
attributes:attributes
placements:nil
onLoad:^{
// Optional callback for when the Rokt placement loads
} onUnLoad:^{
// Optional callback for when the Rokt placement unloads
} onShouldShowLoadingIndicator:^{
// Optional callback to show a loading indicator
} onShouldHideLoadingIndicator:^{
// Optional callback to hide a loading indicator
} onEmbeddedSizeChange:^(NSString *selectedPlacement, CGFloat widgetHeight) {
// Does not required for Full screen overlay
}];
}
Embedded Placement Example
To run an embedded placement in the sandbox environment, the list of attributes passed to Rokt needs to be updated to include "rokt.testsession": "true"
. This can be done by updating the code from Step 6 of Launching an Embedded Placement to the following:
Swift
import Rokt_Widget
class OrderConfirmationViewController: UIViewController {
// linked to RoktEmbeddedView created in step 5 or it could be created programmatically
@IBOutlet weak var roktEmbeddedView: RoktEmbeddedView!
...
// call this function when placement needs to be shown
func showWidget() {
let attributes = ["email": "j.smith@example.com",
"rokt.testsession": "true",
"firstname": "Jenny",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"]
let placements: [String : RoktEmbeddedView] = ["RoktEmbedded1": roktEmbeddedView]
Rokt.execute(viewName: "RoktEmbeddedExperience", attributes: attributes, placements: placements, onLoad: {
// Optional callback for when the Rokt placement loads
}, onUnLoad: {
// Optional callback for when the Rokt placement unloads
}, onShouldShowLoadingIndicator: {
// Optional callback to show a loading indicator
}, onShouldHideLoadingIndicator: {
// Optional callback to hide a loading indicator
}, onEmbeddedSizeChange: { selectedPlacement, widgetHeight in
// Optional callback to get selectedPlacement and height required by the placement every time the height of the placement changes
})
}
}
Objective-C
#import <Rokt_Widget/Rokt_Widget-Swift.h>
...
// call this function when the placement needs to be shown
- (void)showWidget {
NSDictionary *attributes = @{
@"email" : @"j.smith@example.com",
@"rokt.testsession" : @"true",
@"firstname": @"Jenny",
@"lastname": @"Smith",
@"mobile": @"(555)867-5309",
@"postcode": @"90210",
@"country": @"US"
};
// roktEmbeddedView is @property (weak, nonatomic) IBOutlet RoktEmbeddedView *roktEmbeddedView; in .h which points to roktEmbeddedView defines in step 5 or it could be created programmatically
NSDictionary<NSString *, RoktEmbeddedView *> *placements= [NSDictionary dictionaryWithObject:self.roktEmbeddedView forKey:@"RoktEmbedded1"];
[Rokt executeWithViewName:@"RoktExperience"
attributes:attributes
placements:placements
onLoad:^{
// Optional callback for when the Rokt placement loads
} onUnLoad:^{
// Optional callback for when the Rokt placement unloads
} onShouldShowLoadingIndicator:^{
// Optional callback to show a loading indicator
} onShouldHideLoadingIndicator:^{
// Optional callback to hide a loading indicator
} onEmbeddedSizeChange:^(NSString *selectedPlacement, CGFloat widgetHeight){
// Optional callback to get selectedPlacement and height required by the placement every time the height of the placement changes
}];
}