Invitation API - Custom Layout

If you would like to design you own invitation ,the invite can be customized by implementing one of the CustomContactInviteListener, CustomImmediateInviteListener or CustomLocalInviteListener listeners (based on your invitation mode). You can learn more from our sample application on GitHub.

CustomContactInviteListener

Here is the list of methods available in this listener that you can use in order to customize the invite experience.
For more info, Please refer to our API documentation.

  • showInvite
  • onContactFormatError
  • onContactMissing
  • onInviteCompleteWithAccept
  • onInviteCompleteWithDecline
  • onInviteCancelledWithNetworkError
  • onInviteNotShownWithNetworkError
  • onInviteNotShownWithEligibilityFailed
  • onInviteNotShownWithSamplingFailed

CustomImmediateInviteListener

Here is the list of methods available in this listener that you can use in order to customize the invite experience.
For more info, Please refer to our API documentation.

  • showInvite
  • onSurveyPresented
  • onSurveyCompleted
  • onSurveyCancelledByUser
  • onSurveyCancelledWithNetworkError
  • onInviteCompleteWithAccept
  • onInviteCompleteWithDecline
  • onInviteNotShownWithNetworkError
  • onInviteNotShownWithEligibilityFailed
  • onInviteNotShownWithSamplingFailed

CustomLocalInviteListener

Here is the list of methods available in this listener that you can use in order to customize the invite experience.
For more info, Please refer to our API documentation.

  • showInvite
  • onInviteCompleteWithAccept
  • onInviteCompleteWithDecline
  • onInviteNotShownWithNetworkError
  • onInviteNotShownWithEligibilityFailed
  • onInviteNotShownWithSamplingFailed

A Simple Example

ForeSee.setInviteListener(new CustomContactInviteListener() {
    @Override
    public void showInvite(MeasureConfiguration measureConfiguration) {
        // The SDK is ready to show an invite. 
        // This is where you should show your invite UI

        // You can pass the user's contact info at any point 
        // using ForeSee.setContactDetails("555-555-5555")  

        // and inform the SDK whether they accepted or declined the invitation 
        // using ForeSee.customInviteAccepted() and 
        // ForeSee.customInviteDeclined()
    }

    @Override
    public void onContactMissing() {
        // The user's contact info (Email/phone) is required 
        // but was not provided

        // You should ask the user to provide the contact info 
        // and use ForeSee.setContactDetails("5555555555") 
        // to pass the contact info to the SDK,
        // followed by ForeSee.customInviteAccepted() 
    }

    @Override
    public void onContactFormatError() {       
        // The user contact info format is invalid.
 
        // You should ask the user to correct the contact info 
        // and use ForeSee.setContactDetails("user@example.com") 
        // to pass the correct info to the SDK, 
        // followed by ForeSee.customInviteAccepted() 
    }

    @Override
    public void onInviteCompleteWithAccept() {
        // By this point the SDK is finished with the invite process, 
        // this is for information only
        Toast.makeText(getApplicationContext(), "A survey will be sent to "; + ForeSee.getContactDetails(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInviteCompleteWithDecline() {
        Toast.makeText(getApplicationContext(), "Invitation declined by user", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInviteCancelledWithNetworkError() {
        Toast.makeText(getApplicationContext(), "Invitation cancelled with network error", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInviteNotShownWithNetworkError(MeasureConfiguration measureConfiguration) {
        Toast.makeText(getApplicationContext(), "Invitation not shown with network error", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInviteNotShownWithEligibilityFailed(MeasureConfiguration measureConfiguration) {
        Toast.makeText(getApplicationContext(), "Invitation not shown with eligibility failed", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onInviteNotShownWithSamplingFailed(MeasureConfiguration measureConfiguration) {
        Toast.makeText(getApplicationContext(), "Invitation not shown with sampling failed", Toast.LENGTH_SHORT).show();
    }

});

Other articles in this section:

  1. Default Layout
  2. Custom Layout (current article)