Campaign Guides

Campaign Implementation Guides for iOS SDK

Invite & Earn

The following documentation contains a guide for implementing and testing the Invite & Earn Campaign in an iOS Swift Project.

Prerequisites

• App setup with the Flyy SDK. Setup Guide.
• An Invite & Earn Campaign running.


Overview

The referral process starts when the Referrer (User A) shares their referral link from the Offers Page on the app.

After User A has shared the link containing the Referral code, the Referee (User B) can apply the referrer's code in one of the following two ways.

  1. By manually typing in the referral code.
  2. Automatically when the app is downloaded and installed from App Store using the referral link.

Next, the user Signs Up and performs the Event to Reward, say, updating their KYC, which will complete this process and distribute the rewards.

The above makes up the complete referral process.

The referral process on User B's device is summarized in the diagram below. The developer should ensure that User B executes these steps in the exact order for a successful referral.

887

Implementation

Step 1: Initialize SDK with onComplete callback

This step takes care of one of the two ways where referral code is automatically applied.

Within the init method set up a callback by passing an additional argument with the onComplete label and a lambda method.

The onComplete callback will receive the referralCode when the install takes place from the referral link.

🚧

iOS 14.5+

Due to Apple's App Tracking Transparency Policy introduced from iOS 14.5, referral links might not work. Users should therefore be allowed to manually set the referral code as explained in Step 2 below.

Use the callback to perform additional UI-related actions, such as verifying the incoming referrer code. The referrer's code is automatically applied.

Flyy.sharedInstance.initSDK(partnerToken: partnerId, environment: Flyy.FLYY_ENVIRONMENT_STAGING,
                            onComplete: { (success, referralCode) -> Void in
    print(referralCode)
})
[flyy initSDKWithPartnerToken:partnerId environment:[flyy staging] onComplete:^(BOOL success, NSString * referralCode) {
    NSLog(@"Referral Code: %@", referralCode);
}];

Step 2: Set Referral Code

This step takes care of the other way where the referral code is manually applied.

If the user is required to apply the referral code manually, the setReferralCode method should be used as follows.

However, note that the setReferralCode method must be called beforesetNewUser.

Flyy.sharedInstance.verifyReferralCode(referralCode: referralCode,
onComplete: { (success, referralCode) -> Void in
    if(success) {
        Flyy.sharedInstance.setReferralCode(referralCode: referralCode)
    }
})
[flyy verifyReferralCodeWithReferralCode:referralCode onComplete:^(BOOL valid, NSString * referralCode) {
    if(valid) {
        [flyy setReferralCodeWithReferralCode:referralCode];
    }
}];

Step 3: Sign Up

When working with the Acquisition Module campaign, it is necessary that a new user registers with the setNewUser method instead of setUser.

Flyy.sharedInstance.setNewUser(externalUserId: userId)
[flyy setNewUserWithExternalUserId:userId];

Step 4: Trigger Event

The final step to completing the referral process is triggering an event. The rewards will be distributed only after the campaign event is sent.

//Note: Only use the sendEvent method in Staging. For production, make
//an API call from your backend.
//See: https://docs.theflyy.com/docs/create-and-track-your-first-offer#send-event-on-checkout
Flyy.sharedInstance.sendEvent(key: eventKey, value: "true")
//Note: Only use the sendEvent method in Staging. For production, make
//an API call from your backend.
//See: https://docs.theflyy.com/docs/create-and-track-your-first-offer#send-event-on-checkout
[flyy sendEventWithKey:eventKey value:@"true"];

Variant Campaign Event

Follow this step only to implement the variant campaign.

From the implementation standpoint, there is just 1 difference when working with Variant Campaigns and that is the sendEvent method expects Event Data as a JSON object.

The below code sample is about the Variant Campaign created here from the Dashboard.

let jsonobj = ["purchase": "500"]
Flyy.sharedInstance.sendEventWithJson(key: eventKey, value: jsonobj)
NSDictionary *json = @{@"purchase": @500};
[flyy sendEventWithJsonWithKey:eventKey value:json];

After the 4th step, the Flyy Rewards System sends out a scratch card to the Referrer (User A) and Referee (User B).

The Flyy Rewards System performs a few checks to determine if the new users are eligible before giving out the rewards. You may run into these safeguards while testing the Invite & Earn implementation. If you do, you may find possible resolutions in the Test Invite & Earn and the Troubleshooting sections.

Test Invite & Earn

Prerequisites

  • Two mobile devices — one for User A and one for User B. User B's device must be an iOS device.

Use the below 4 steps to test this offer in your own app or download the sample project from GitHub.

The Flyy Rewards System requires that the mobile device used for registering a user should not have been used before for registering any other user. See the Troubleshooting section to learn how to remove users previously registered using the same device.

Test with your app

On User A's device

  • Sign Up and check the Offers Page screen to get the Referral Code.

The referral link will look something like this: https://stage.flyy.in/C8UFPBE.
In this example link C8UFPBE is user A's referral code.

On User B's device

  • Apply the Referral Code shared by User A.
  • Perform Sign Up.
  • Perform the action on User B's device that triggers the "kyc_done" event.

After the event is triggered, the Flyy Rewards System will check if this is a genuine referral and give out the reward containing a Scratch Card and notification to User A and B's devices.

Test with the GitHub Project

Download the Xcode project from GitHub.

Set up FCM notifications and App Store app redirect before starting the test.

Set up FCM Notifications

In your staging dashboard, go to Settings > SDK Keys and provide the following server key:

AAAAgM9X2Bw:APA91bGAcRPmTKjTGTESQfzUsqmCYBRnhQm4KnwuSoOpRKpn1OB5FEdqtF_CFWGMbIUyVIGecIjMwIdtx0XmYlo-dZjpLgtMLvYET9SRfr8uFzzXg441GbFyA8epdibsh3x3UKzD3glG

Redirect to the App Store app

In your staging dashboard, go to Settings > Connect SDK and provide the following App Store link to the app. Leave it blank while we are still testing the implementation.

Then, perform the following steps.

On User A's device

  • Run the project.
  • On the SDK Setup screen, type in the Package Name and Partner Id as it appears in your Staging dashboard.
  • Sign Up with a new User ID.
  • Tap the Invite & Earn button, open the Offer, and Share the Referral Link.

On User B's device

  • Tap on the Referral Link. The link should open on the Safari browser, but it will show an error as we left the app store link field empty.
  • Run the app.
  • Type in the Package Name and Partner Id. Click Next. An alert message indicating whether the Referral Code is valid or invalid will be displayed. If the Referral Code is valid, it is applied without needing any further steps.
    • If the referral code is invalid, manually enter the referral code on the Sign-Up screen.
  • Sign Up with a new User ID.
  • On the Home screen, tap the UPDATE KYC button. This button is calling the sendEvent method with "kyc_done" as the event key in its parameter.

After tapping on the UPDATE KYC button, the Flyy Rewards System determines whether to give out the reward or not and sends a Scratch Card and notification to User A and B's devices.

Troubleshooting

If you are not receiving rewards during testing. See the common problems below.

Multiple Devices with the same Device ID

Users A and B must sign up from unique devices and the same device should not exist on Flyy's dashboard before they sign up.

To verify the uniqueness of the device id, go to Settings > Playground and follow these steps:

  1. Perform a Search with User A's user id.
  2. Copy the Device Id from the search result.
  3. Perform another search with the copied Device Id.
  4. If more than 1 search results show up, delete all records with identical Device Id.

Repeat the same steps for User B.

After you have ensured that all records with the above Device Ids have been deleted, rerun the test.

Notification Issue

Go to Reports > Referrals and check if the new referral record with User A and B record is created. If the new record exists, but the devices do not receive a notification, test your app's FCM configuration.

Also, ensure if the correct Server Key has been provided at Settings > SDK Keys.