Swiftpack.co - GroupeMINASTE/DonateViewController as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by GroupeMINASTE.
GroupeMINASTE/DonateViewController 1.1.5
A view controller to make donations.
⭐️ 6
🕓 3 weeks ago
.package(url: "https://github.com/GroupeMINASTE/DonateViewController.git", from: "1.1.5")


License Issues Pull Requests Code Size CodeFactor Open Source Helpers

A view controller to make donations.


Add https://github.com/GroupeMINASTE/DonateViewController.git to your Swift Package configuration (or using the Xcode menu: File > Swift Packages > Add Package Dependency)


⚠️ You need to register your in app purchases in App Store Connect to make it work. The name and the price of purchases will be used.

First, import the package in your view controller where you want to open the DonateViewController.

// Import the package
import DonateViewController

Create a method to open it:

// Import the package
import DonateViewController

class MyViewController: UIViewController {

    // Some code...

    func openDonateViewController() {
        // Create the view controller
        let controller = DonateViewController()
        // Customize view title, header and footer (optional)
        controller.title = "Donate"
        controller.header = "Select an amount to donate:"
        controller.footer = "The donations help us to improve our projects (...)"
        // Add a delegate to get notified when a donation ends
        controller.delegate = self
        // Add donations
        controller.add(identifier: "my.app.identifier.mydonation1")
        controller.add(identifier: "my.app.identifier.mydonation2")
        // ... (add as many donations as you want)
        // And open your view controller: (two ways)
        // 1. In your navigation controller
        navigationController?.pushViewController(controller, animated: true)
        // 2. In a modal
        present(UINavigationController(rootViewController: controller), animated: true, completion: nil)

    // Some code...


Then you need to implement the DonateViewControllerDelegate protocol to get notified when a donation ends:

// Import the package
import DonateViewController

class MyViewController: UIViewController, DonateViewControllerDelegate { // Add the protocol to the view controller

    // Some code...
    // The method we just created (no changes)
    func openDonateViewController() {
        // ...
    // Implement delegate methods
    func donateViewController(_ controller: DonateViewController, didDonationSucceed donation: Donation) {
        // Handle when the donation succeed
    func donateViewController(_ controller: DonateViewController, didDonationFailed donation: Donation) {
        // Handle when the donation failed
    // Some code...


You can show a UIAlertController with a little message for exemple.

And call the openDonateViewController() method when you want to open the DonateViewController:


This can be called when the user clicks on a UIButton (in the selector method) or when the user selects a table view cell.

That's all, you're ready to receive donations!

Customize colors for theming (iOS < 13)

Before iOS 13, no dark theme was implemented in controllers. If you want to implement your custom dark theme, subclass DonateViewController and DonateCell to change the colors of the views. (background, ...)

Donate to the developer

Feel free to make a donation to help the developer to make more great content! Donate now


Stars: 6
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

DonateViewController v1.1.5
2 years ago

Fixing a bug with mac catalyst

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics