iOS SDK
Install and use the GrowSurf iOS SDK to capture referral attribution, create referred participants, and show a native referral window in your app.
Install
The core library is lightweight, adding roughly ~2.6 MB (uncompressed device binary) to your iOS app (attribution adapters add only tens of KB each).
Choose one install path.
Add the SDK from the public v0.4.0 podspec:
growsurf_podspec = 'https://raw.githubusercontent.com/growsurf/growsurf-ios-sdk-distribution/v0.4.0/GrowSurfSDK.podspec'
pod 'GrowSurfSDK', :podspec => growsurf_podspecOptional attribution adapter subspecs:
pod 'GrowSurfSDK/BranchAttribution', :podspec => growsurf_podspec
pod 'GrowSurfSDK/AdjustAttribution', :podspec => growsurf_podspec
pod 'GrowSurfSDK/AppsFlyerAttribution', :podspec => growsurf_podspec
pod 'GrowSurfSDK/SingularAttribution', :podspec => growsurf_podspecIn Xcode, add the public binary package repository:
https://github.com/growsurf/growsurf-ios-sdk-distribution.gitChoose version 0.4.0 or later, then add the GrowSurfSDK product to your app target.
For a Package.swift target:
dependencies: [
.package(url: "https://github.com/growsurf/growsurf-ios-sdk-distribution.git", from: "0.4.0"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "GrowSurfSDK", package: "growsurf-ios-sdk-distribution"),
]
),
]Optional attribution adapter products are available from the same package:
GrowSurfBranchAttributionGrowSurfAdjustAttributionGrowSurfAppsFlyerAttributionGrowSurfSingularAttribution
The optional GrowSurfGoogleContacts product additionally pulls in Google Sign-In, so add it only if you want the native in-app Google contacts sign-in sheet.
Download
GrowSurfSDK.xcframework.zipfrom the publicv0.4.0release.Unzip it and drag
GrowSurfSDK.xcframeworkinto your Xcode project.In your app target, set
GrowSurfSDK.xcframeworkto Embed & Sign.Add optional adapter XCFrameworks the same way when you use Branch, Adjust, AppsFlyer, or Singular helpers.
Initialize
Enable Mobile SDK access in your GrowSurf program on the instructions page, then configure the SDK once when your app starts or before your first GrowSurf call.
Find
campaignIdin your GrowSurf program dashboard. It is the 6-character program ID, such asp9josq.Find
publicKeyin Program Editor > 5. Installation > Instructions page > Step 1. iOS > Configure SDK.
Track referrals
Tracking referrals entails capturing attribution and creating new referred participants.
Capture attribution
Capture referral attribution before you create the referred friend's participant record.
For direct app links that open your installed app:
For deferred deep links from an attribution provider:
Unlike Android (which reads the Play Install Referrer for native deferred attribution), iOS has no native deferred deep link mechanism, so deferred attribution is delegated to your attribution provider (e.g., Branch, AppsFlyer). View Adapter docs for your specific provider setup instructions.
Create a referred participant
Use addReferredParticipant() for referred signups. This is typically where new users sign up in your app.
The SDK validates saved or explicit attribution and only creates the participant when the referral code is valid.
Generate referral links for your users
Generating referral links to users in your app entails generating a participant token by using the GrowSurf API, then opening the GrowSurf window.
Generate a participant token
To allow authenticated access to your logged-in users, you must call the GrowSurf backend to generate a participant token.
Call backend endpoint create a mobile participant token.
Here is an example cURL command:
Only email is required. firstName, lastName, mobileInstanceId, and ipAddress are optional participant fields. metadata is optional and is not used by GrowSurf.
Optional: To get the SDK-generated mobileInstanceId, use mobileInstanceId().
This will create a new participant or return an existing one, along with a participant token that allows authenticated calls.
Pass it to the app, then store in the SDK via setParticipantToken().
Here is example SDK code:
Show the GrowSurf window



The GrowSurf window allows your participants to view/share their referral link and track the status of their referrals and rewards.
Call presentGrowSurfWindow() from your own button, menu item, or referral screen. Set the identity parameter to .existingParticipantToken(), which will use the participant token you generated above.
[Optional] Google Contacts invites


Only needed when Google Contacts invites are enabled for your program. When enabled, the native GrowSurf window can read the participant's Google contacts (read-only) so they can pick people to invite.
This works out of the box — the core GrowSurfSDK uses a dependency-free external-browser sign-in flow, so there is no extra dependency to install for the default experience.
To use the native in-app Google Sign-In sheet instead (a smoother flow that doesn't leave your app), add the optional GrowSurfGoogleContacts product. It bundles Google Sign-In, so it is kept out of the core SDK — apps that don't use it never link GoogleSignIn.
Add the GrowSurfGoogleContacts product from the growsurf-ios-sdk-distribution package to your app target (alongside GrowSurfSDK).
First complete the Google Cloud setup to create your OAuth client and add your iOS Client ID and reversed-client-ID URL scheme to your GrowSurf campaign. The steps below are the additional in-app setup the in-app Google Sign-In sheet needs — without them the in-app sign-in will fail even when your campaign is configured correctly.
Enable the in-app GoogleSignIn flow at app startup, before opening a GrowSurf window that offers Google contacts import:
Register your Google reversed-client-ID URL scheme in Info.plist.
Add a CFBundleURLTypes entry whose CFBundleURLSchemes value is your reversed client ID (the REVERSED_CLIENT_ID from your GoogleService-Info.plist / OAuth client, in the form com.googleusercontent.apps.XXXXXXXX).
Forward incoming URLs to GrowSurf from your app's URL-open handler so the Google Sign-In callback is handled:
Either way, the SDK requests only the contacts.readonly scope and imports the participant's primary Google connections.
Log out
If your user logs out of your app, call shutdown() to remove all participant data from the device:
Next steps
Attribution ProvidersAPI ReferenceModels and ErrorsGetting Started for Native MobileLast updated
Was this helpful?