iOS SDK
FlockSdk is a Swift package that simplifies the integration of Flock’s referral and customer identification features into your iOS application. This guide outlines the setup and usage of FlockSdk in a Swift-based iOS app.
Installation
1. Add FlockSdk to Your Project
Using Swift Package Manager (SPM):
- Open your Xcode project.
- Go to File > Add Packages.
- Enter the repository URL for FlockSdk:
https://github.com/flock-solutions/ios-sdk
. - Select a version and add the package to your project.
Usage
1. Initialize the SDK
In your AppDelegate
or SceneDelegate
, configure the SDK with your publicAccessKey
:
2. Identify Customers
The identify
method should be called after a user successfully logs in or creates an account. This links the user’s details to their Flock account.
Example:
3. Open Referrals WebView
To show the referral page for an referrer, use the openPage
method with the referrer
page type. You can handle events like the closed
action.
Example:
4. Open Invitee WebView
For an invitee, use the openPage
method with the invitee
page type. This method supports onSuccess
, onInvalid
, and closed
callbacks.
Example:
5. Post-Success Flow for Invitees (Optional)
After a successful onboarding of an invitee, you can choose to either navigate the user to your custom success page or open a Flock-hosted success page. Use the openHostedSuccessPage method for the latter option.
Example:
Notes
Error Handling
- Ensure network errors are handled when calling
identify
. - Provide fallback UI if the WebView fails to load.
Testing
- Use mock APIs during development to avoid triggering actual requests to Flock’s backend.
FAQ
Q: What iOS versions are supported?
A: FlockSdk supports iOS 11.0 and above.
Q: Can I customize WebView actions?
A: Yes, you can use the event handlers provided for WebView methods to customize the behavior.
Support
For questions or issues, contact the Flock support team at support@withflock.com.
Thank you for using FlockSdk!