Pre-populating a Voucher

The Voucher Create Flow process can be started with personalizations already added. Some examples of prepopulating are:

  1. Creating a gift with a Merchant (eg. Gift Card).
  2. Sending a gift to a specific User (ie. sending back to someone).
  3. Sending an occasion with preset VoucherMedias. (eg. Happy Birthday).

To pre-populate simply start the VoucherCreationFlowCoordinator normally and then call populateWithVoucher:

Example pre-population

// Prepopulate with wrapping paper, a game, and a couple of media items.
MutableVoucher *mutableVoucher = [MutableVoucher new];
mutableVoucher.wrappingPaper = defaultWrappingPaper;
mutableVoucher.gameData = [GameManager gameDatas].firstObject;
[mutableVoucher addMedia:[ImageMedia imageMediaWithId:0 data:imageData animated:NO width:300 height:300]];
[mutableVoucher addMedia:[[NoteMedia alloc] initWithText:@"Happy Birthday!" font:[UIFont systemFontOfSize:12] colorString:@"#ff00ff" angle:0 size:12]]];

[self.voucherCreationFlowCoordinator startFlowOnViewController:self 
                                        personalizationOptions:personalizationOptions
[self.voucherCreationFlowCoordinator populateWithVoucher:mutableVoucher];