Trigger - Custom Invites

Clients may use the SDK to create entirely custom invites that not only control appearance, but also handle user interaction.

Note
Custom invites provide complete control over an invite’s appearance, but are more difficult to implement. The default invite is adequate for most uses.

Creating a custom invite

Clients must (at a minimum) do the following things to show a custom invite:

  1. Create a custom invite handler that conforms to the FSInviteHandler protocol. This protocol declares methods that will be called when the SDK wants to show an invite, close an invite, or when there is an error.
  2. Register the invite handler with the SDK using [ForeSee setInviteHandler:myCustomInviteHandler];
  3. Notify the SDK when an invite has been accepted or declined using the following methods:
    [ForeSee customInviteAccepted];

    [ForeSee customInviteDeclined];

The SDK will track everything necessary to determine a user’s eligibility. If a user passes the eligibility criteria you’ve previously defined (and is in the sampling pool) and a custom invite handler has been registered, then the SDK will call the following method on that invite handler:

- (void)showAndOnCompletion:(void(^)())completion;

Your implementation of this method should handle presentation of your custom views. You must also notify the SDK when the user has accepted or declined your invite.

If the user accepts your invite, then call:

[ForeSee customInviteAccepted];

If the user declines your invite, then call:

[ForeSee customInviteDeclined];

The SDK will determine when it’s safe to dismiss your custom invite and call the following method once all processing is complete:

- (void)hideWithAnimation:(BOOL)animate completion:(void (^)())completion;

Your implementation of this method should handle hiding your custom invite.

The SDK’s public protocols are fully documented on Cocoadocs.

Custom CONTACT invites

Custom invites that use the CONTACT invite mode have additional requirements. Namely, you must provide the SDK with the user’s contact details. (The default invite presents a text box to the user and requires that they manually enter this information.) However you get the details from the user, you must provide them to the SDK using:

[ForeSee setContactDetails:@"email or phone number"];

If the SDK has invalid input at the time that a custom CONTACT invite is accepted, then it will call the following delegate method:

- (void)setInvalidInput:(BOOL)isInvalid;

It is up to the custom invite handler to decide how to handle this error (e.g. ask the user to correct the information or treat it as a failure).

Note v4.0.0
This method is at present only called when the given input is invalid (i.e. isInvalid will never be NO). This may change in a future release, so checking the value is still recommended.

The SDK’s public protocols are fully documented on Cocoadocs.

Other articles in this section:

  1. Trigger Overview
  2. Invite Modes
  3. Repeat Days
  4. Sampling
  5. Multiple Measures
  6. CPP's
  7. Localization
  8. Custom Invites (current article)
  9. SDK Events