Pre-Population
The Voucher Create Flow process can be started with personalizations already added. Some examples of prepopulating are:
- Creating a gift with a
VOMerchant
(eg. Gift Card). - Sending a gift to a specific
VOUser
(ie. sending back to someone). - Sending an occasion with preset
VOVoucherMedia
s. (eg. Happy Birthday).
To pre-populate simply start the VOVoucherCreationFlowCoordinator
normally and then call populateWithVoucher
:
Example Pre-population
// Prepopulate with wrapping paper, a game, and a couple of media items.
VOMutableVoucher *mutableVoucher = [VOMutableVoucher new];
mutableVoucher.wrappingPaper = defaultWrappingPaper;
mutableVoucher.gameData = [VOGameManager gameDatas].firstObject;
[mutableVoucher addMedia:[VOImageMedia imageMediaWithId:0 data:imageData animated:NO width:300 height:300]];
[mutableVoucher addMedia:[[VONoteMedia alloc] initWithText:@"Happy Birthday!" font:[UIFont systemFontOfSize:12] colorString:@"#ff00ff" angle:0 size:12]]];
[self.voucherCreationFlowCoordinator launchPreviewScreenOnViewController:self
personalizationOptions:[self personalizations]
vouchrTheme:self.defaultVouchrTheme
creationManager:self.creationManager
flowCoordinator:self.voucherCreationFlowCoordinator
voucher:(VOVoucher *)mutableVoucher];
// Prepopulate with wrapping paper, and a couple of media items.
let mutableVoucher = VOMutableVoucher()
mutableVoucher.wrappingPaper = defaultWrappingPaper;
mutableVoucher.gameData = VOGameManager.gameDatas().first
mutableVoucher.addMedia(VOImageMedia(id: 0, data: imageData, animated: false, width: 300, height: 300))
mutableVoucher.addMedia(VONoteMedia(text: "Happy birthday", font: UIFont.systemFont(ofSize: 12), colorString: "#ff00ff", angle: 0, size: 0))
voucherCreationFlowCoordinator.launchPreviewScreen(on: self, personalizationOptions: personalizations(), vouchrTheme: defaultVouchrTheme, creationManager: creationManager, flowCoordinator: voucherCreationFlowCoordinator, voucher: mutableVoucher as? VOVoucher)