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, and a couple of media items.
let mutableVoucher = MutableVoucher()
mutableVoucher.wrappingPaper = defaultWrappingPaper;
mutableVoucher.addMedia(ImageMedia(id: 0, data: imageData, animated: false, width: 300, height: 300))
mutableVoucher.addMedia(NoteMedia(text: "Happy birthday", font: UIFont.systemFont(ofSize: 12), colorString: "#ff00ff", angle: 0, size: 0))

self.voucherCreationFlowCoordinator.startFlow(on: self, personalizationOptions: personalizationOptions);
self.voucherCreationFlowCoordinator.populateWithVoucher(mutableVoucher)