# TikTok-Style Referral Code and Invite UI in SwiftUI

> By Lawrence Arya, Founder & CEO of VP0. Published 2026-06-02, updated 2026-06-04. 5 min read.
> Source: https://vp0.com/blogs/tiktok-style-referral-code-invite-ui-swiftui

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

**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](https://developer.apple.com/design/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](https://developer.apple.com/documentation/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.

### Deep links for attribution

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 element | iOS API | What it does |
|---|---|---|
| Copy code | UIPasteboard | One-tap copy with haptic confirm |
| Invite button | ShareLink / UIActivityViewController | Native system share sheet |
| Reward progress | ProgressView / custom bar | Visible path to the unlock |
| Invited list | List / LazyVStack | Shows who has joined |
| Install attribution | Universal Links | Routes the code into the app |
| Reward delivery | StoreKit | Grants 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](https://developer.apple.com/documentation/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](/blogs/tvos-netflix-clone-ui-swiftui/).

## 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](/blogs/vision-pro-iphone-companion-app-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.

## Frequently asked questions

### 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.

---
*Published on the [VP0 Journal](https://vp0.com/blogs). Free to read, index and cite with attribution.*
