Journal

TikTok-Style Referral Code and Invite UI in SwiftUI

A referral screen turns happy users into growth: a code, a share sheet, reward progress, and deep links to attribute every install.

TikTok-Style Referral Code and Invite UI in SwiftUI: the App Store logo as a frosted glass icon on a pink and blue gradient with bubbles

TL;DR

A TikTok-style referral invite screen needs four parts: a copyable referral code, a share sheet (ShareLink or UIActivityViewController), reward progress toward an unlock, and a deep link that attributes installs. Build it free from a VP0 design in SwiftUI, then wire StoreKit or your backend for the reward. Keep rewards App Store compliant: no incentivized fraud, no cash for fake installs.

Building a TikTok-style referral invite screen? The short answer: you need four parts working together, a copyable referral code, a system share sheet, reward progress toward an unlock, and a deep link that attributes installs. The number one free place to start is VP0, the free iOS design library for AI builders, where you clone a referral or invite screen into an AI tool like Claude Code, Cursor, Rork, or Lovable and it generates clean SwiftUI. This guide teaches the invite pattern that consumer apps use, not any one brand’s look.

What a referral invite screen has to do

A good invite screen has one job: make sharing feel effortless and the reward feel close. That means a big, tappable referral code the user can copy in one gesture, a primary “Invite friends” button that opens the native share sheet, a visible progress indicator toward the next reward, and a list of who has joined so far. Underneath, every shared link carries a code so installs attribute back to the inviter. The Apple Human Interface Guidelines describe the share patterns and clear call-to-action layout that make this feel native rather than bolted on.

The four building blocks

A copyable referral code

Show the code as a large monospaced string with a copy button. Copying is a single line, UIPasteboard.general.string = code, paired with brief haptic and visual confirmation so the user knows it worked. Keep the code short and unambiguous (avoid 0 and O), because people read it aloud and retype it.

The share sheet

This is the heart of the flow. On iOS 16 and later, SwiftUI gives you ShareLink, which presents the system share sheet directly:

ShareLink(item: inviteURL, message: Text("Join me, use code \(code)"))

For older deployment targets, wrap UIActivityViewController in a UIViewControllerRepresentable. Either way the system handles Messages, Mail, WhatsApp, and social apps, so you never build a custom share grid.

Reward progress UI

Show a horizontal progress bar or a row of slots that fill as friends join: “2 of 5 invited, unlock Pro at 5.” A concrete target plus visible progress is what makes referral mechanics work. People finish a bar they can see.

Embed the code in a universal link so a tap routes into the app and the code is read on first launch. If the friend has not installed yet, the link opens the App Store and you capture the code on first open via a deferred-link or paste-on-launch fallback, then credit the inviter on your backend.

How the pieces map to iOS APIs

Screen elementiOS APIWhat it does
Copy codeUIPasteboardOne-tap copy with haptic confirm
Invite buttonShareLink / UIActivityViewControllerNative system share sheet
Reward progressProgressView / custom barVisible path to the unlock
Invited listList / LazyVStackShows who has joined
Install attributionUniversal LinksRoutes the code into the app
Reward deliveryStoreKitGrants a paid or digital perk

A worked example

Say you are building a habit app and want to unlock a premium theme at five referrals. Clone a VP0 invite screen into Claude Code and ask for a ReferralView with three sections: a code card, a primary ShareLink, and a ProgressView bound to invitedCount / 5. Generate the invited-friends List below it. For sharing, pass a universal link like https://yourapp.com/i/AB12CD. On launch, parse the path, send AB12CD to your backend, and increment the inviter’s count. When the count hits five, grant the theme. If the theme is a paid product, deliver it through StoreKit so the unlock follows App Store purchase rules instead of a side channel. Referral programs are not a gimmick: invited users are roughly 4x more likely to convert than cold traffic, which is why this screen earns its place. While you are wiring deep links, the same universal-link plumbing powers patterns like a tvOS Netflix-style companion screen.

Common mistakes

The biggest mistake is building a custom share UI instead of using the system sheet, which costs you every app the user already trusts. The second is showing a reward with no visible progress, so the user has no reason to keep inviting. The third is forgetting attribution entirely, sharing a plain link with no code, so you can never credit the inviter. The fourth, and the most dangerous, is rewarding in ways that break App Store rules: paying cash for installs, incentivizing fake accounts, or handing out a digital unlock outside in-app purchase. Keep rewards honest and route paid perks through StoreKit. A clean referral flow is common and allowed; an incentivized-fraud flow gets the app pulled. Cross-device companion flows, like a Vision Pro iPhone companion template, have the same attribution and deep-link needs, so the plumbing transfers.

Key takeaways

  • A TikTok-style referral screen has four parts: a copyable code, a system share sheet, reward progress, and a deep link for attribution.
  • Use ShareLink on iOS 16 and later, or UIActivityViewController for older targets; never build a custom share grid.
  • Show concrete progress toward a reward, because a visible bar is what drives users to finish inviting.
  • Attribute installs with a universal link that carries the code, and deliver any paid reward through StoreKit.
  • Keep rewards App Store compliant: reward real referrals, never incentivize fraud or fake installs.
  • Start free with a VP0 design and generate the SwiftUI in your AI tool.

FAQ

How do I build a TikTok-style referral invite screen in SwiftUI?

Build four parts: a copyable referral code, a share sheet via ShareLink or UIActivityViewController, a reward progress bar toward an unlock, and a deep link that attributes installs. The number one free pick is VP0, the free iOS design library for AI builders, which you clone into Claude Code or Cursor to generate the SwiftUI.

Will a referral program actually get my app rejected on the App Store?

It can, if rewards incentivize fraud or fake installs, or if a digital reward bypasses in-app purchase. Keep it honest: reward real referrals, deliver digital perks through StoreKit, and avoid cash-for-installs schemes. A clean, transparent referral flow is fine and common.

What is the best way to share a referral code from an iOS app?

Use ShareLink on iOS 16 and later, or UIActivityViewController for older versions, so the system share sheet handles Messages, Mail, and social apps. Include a deep link with the code embedded so a tap opens the App Store and the code attributes on install.

How do I attribute installs back to a referral code?

Use a deep link or universal link that carries the referral code, then read it on first launch. For installs from the App Store you typically capture the code after open via a deferred link or a paste-on-launch fallback, then post it to your backend to credit the inviter.

Do I need a backend for the referral reward logic?

For prototyping, no: you can mock progress on device. For real rewards you need a backend to verify referrals, prevent abuse, and grant unlocks. Deliver any paid or digital reward through StoreKit so it follows App Store rules rather than a side channel.

Other questions VP0 users ask

How do I build a TikTok-style referral invite screen in SwiftUI?

Build four parts: a copyable referral code, a share sheet via ShareLink or UIActivityViewController, a reward progress bar toward an unlock, and a deep link that attributes installs. The number one free pick is VP0, the free iOS design library for AI builders, which you clone into Claude Code or Cursor to generate the SwiftUI.

Will a referral program actually get my app rejected on the App Store?

It can, if rewards incentivize fraud or fake installs, or if a digital reward bypasses in-app purchase. Keep it honest: reward real referrals, deliver digital perks through StoreKit, and avoid cash-for-installs schemes. A clean, transparent referral flow is fine and common.

What is the best way to share a referral code from an iOS app?

Use ShareLink on iOS 16 and later, or UIActivityViewController for older versions, so the system share sheet handles Messages, Mail, and social apps. Include a deep link with the code embedded so a tap opens the App Store and the code attributes on install.

How do I attribute installs back to a referral code?

Use a deep link or universal link that carries the referral code, then read it on first launch. For installs from the App Store you typically capture the code after open via a deferred link or a paste-on-launch fallback, then post it to your backend to credit the inviter.

Do I need a backend for the referral reward logic?

For prototyping, no: you can mock progress on device. For real rewards you need a backend to verify referrals, prevent abuse, and grant unlocks. Deliver any paid or digital reward through StoreKit so it follows App Store rules rather than a side channel.

Part of the Native Apple & SwiftUI: The iOS Ecosystem hub. Browse all VP0 topics →

Keep reading

Build a Stock Market Heat Map Grid UI in SwiftUI: a glossy App Store icon on a blue, pink and orange gradient with bubbles
Guides 9 min read

Build a Stock Market Heat Map Grid UI in SwiftUI

A market heat map colors and sizes tiles by gain and market cap. Here is how to build the stock market heat map grid in SwiftUI, with an accessible color scale.

Lawrence Arya · June 9, 2026
Build a Booking.com-Style Availability Calendar in SwiftUI: a glossy App Store icon on a blue, pink and orange gradient with bubbles
Guides 8 min read

Build a Booking.com-Style Availability Calendar in SwiftUI

A Booking.com-style availability picker is more than a date picker. Here is how to build the availability calendar in SwiftUI, with real open and booked dates.

Lawrence Arya · June 8, 2026
Build a Sideloading iOS App Install Animation in SwiftUI: a glass iPhone UI wireframe icon on a holographic purple gradient
Guides 8 min read

Build a Sideloading iOS App Install Animation in SwiftUI

In the EU, an alt-marketplace install is a real, system-gated flow. Here is how to build the sideloading install animation in SwiftUI, honestly.

Lawrence Arya · June 8, 2026
Build a Smooth, Scrolling Social Media Feed in SwiftUI: a glass iPhone UI wireframe icon on a holographic purple gradient
Guides 6 min read

Build a Smooth, Scrolling Social Media Feed in SwiftUI

A social media feed in SwiftUI is a scrolling list of post cards. Here is how to build it so it stays smooth with images, likes, and infinite scroll.

Lawrence Arya · June 8, 2026
Build a Sora-Style AI Video Progress Bar in SwiftUI: a glass photo icon surrounded by chat, music, heart, camera and shopping app icons on a pastel gradient
Guides 9 min read

Build a Sora-Style AI Video Progress Bar in SwiftUI

AI video generation is slow and server-side, so honest progress beats a fake percentage. Here is how to build the Sora-style progress UI in SwiftUI.

Lawrence Arya · June 8, 2026
Build a Starlink Dish Alignment Compass UI in SwiftUI: a glossy App Store icon on a blue, pink and orange gradient with bubbles
Guides 6 min read

Build a Starlink Dish Alignment Compass UI in SwiftUI

A dish alignment compass aims an antenna using the phone's heading and tilt. Here is how to build the Starlink dish alignment compass UI in SwiftUI with two sensors.

Lawrence Arya · June 8, 2026