Integrate with sandbox
With a sandbox integration, you can include a configuration flag to test against a sandbox environment. The sandbox environment follows a normal offers, bidding, and matching process against your production configuration. While a sandbox environment is part of the Rokt production environment, it does not charge advertisers or generate revenue. As a result, you can use it for acceptance testing before deploying to production.
The integration follows exactly the same steps as in previous examples, with an additional sandbox
attribute required in the execute
function.
You must remove the sandbox
attribute before going live with your placement.
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 "sandbox": "true"
. This can be done by updating the sample code from the adding an overlay placement documentation to include the following:
- Swift
- Objective-C
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",
"sandbox": "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
})
}
}
#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",
@"sandbox" : @"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, you need to update the list of attributes passed to Rokt to include "sandbox": "true"
. This can be done by updating the sample code from the adding an embedded placement documentation to the following:
- Swift
- Objective-C
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",
"sandbox": "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
})
}
}
#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",
@"sandbox" : @"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
}];
}