Skip to content

feat(InAppPurchaseView): allow inserting custom view content#1

Open
porcupine072 wants to merge 3 commits intoadamfootdev:mainfrom
porcupine072:custom-content-insertion
Open

feat(InAppPurchaseView): allow inserting custom view content#1
porcupine072 wants to merge 3 commits intoadamfootdev:mainfrom
porcupine072:custom-content-insertion

Conversation

@porcupine072
Copy link
Copy Markdown

@porcupine072 porcupine072 commented Apr 4, 2026

Good day,

First, I would like to express my gratitude for this package. It has definitely saved me countless weeks of work.

I was able to add a one-off lifetime purchase tier with your package with ease. It is in production in my Mac app :)

This PR is a simple one. My motivation is I want to run a promotion using App Store Offer Codes. Displaying wording about the promotion in InAppPurchaseKit is important because it is the source of truth when a user is deciding to make a purchase.

If I have a View stating the promotion event in the app elsewhere, I run the risk of the user not seeing that View.

This PR adds the ability to simply inject a View at a given point in the hierarchy of InAppPurchaseView.

Such a PR would allow me to achieve my goal without getting messy in forking and maintaining a separate repository for this package.

It may be useful for others as well. Who knows.

Thanks again for your work here, I'm sure you have saved many a lot of time.

@adamfootdev
Copy link
Copy Markdown
Owner

Hi,

Thanks for the feedback and I can see a feature like this being useful!

To improve it, I think CustomContentInsertionPoint should be removed and instead replaced by an enum that enables the developer to fully control the order of content. For example, the could put features above/below the tiers. The enum would then have a case where the developer could pass in a custom view. A default order of how it is at the moment would be set in the initialiser.

Thanks

@porcupine072
Copy link
Copy Markdown
Author

Agreed, that would be a cleaner approach.

I’ll look into it.

@porcupine072
Copy link
Copy Markdown
Author

Hey Adam, I've made the changes you suggested. This approach does feel much cleaner now.
InAppPurchaseView accepts contentOrder for custom ordering and also for adding custom views at will.

The enum InAppPurchaseViewContent has the static var defaultOrder.

Ordering can be customized, for example:

InAppPurchaseView(
    contentOrder: [
        .header,
        .custom(AnyView(
            Text("Limited-time discount")
                .font(.headline)
        )),
        .tiers,
        .features,
        .additionalOptions
    ]
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants