Search code examples
androidiosapptentive

Apptentive callback methods


Are there any Apptentive callback methods which inform us what is happening?

For example,

[[ATConnect sharedConnection] engage:@"completed_level" fromViewController:viewController];

tells Apptentive an event has occured, and now Apptentive might display an interaction.

After an event is logged, I would like to know whether:

  • an interaction will be displayed
  • an interaction is displaying
  • interaction has been completed

Is there currently a way to do this?


Solution

  • The return value of engage:fromViewController: indicates whether or not an interaction was shown for the event:

    BOOL interactionShown = [[ATConnect sharedConnection] engage:@"event" fromViewController:vc];
    if (interactionShown) {
        // Interaction (Survey, Rating Prompt, etc) was shown.
    } else {
        // No interaction was shown.
    }
    

    You can also use the method willShowInteractionForEvent: to know if an interaction will be shown the next time you engage an event:

    BOOL availableSurvey = [[ATConnect sharedConnection] willShowInteractionForEvent:@"show_survey_event"];
    if (availableSurvey) {
        // Show "Show Survey" button.
    } else {
        // Hide "Show Survey" button.
    }
    

    Apptentive also posts some notifications that you can listen for and respond to via NSNotificationCenter:

    /** Notification sent when Message Center unread messages count changes. */
    extern NSString *const ATMessageCenterUnreadCountChangedNotification;
    
    /** Notification sent when the user has agreed to rate the application. */
    extern NSString *const ATAppRatingFlowUserAgreedToRateAppNotification;
    
    /** Notification sent when a survey is shown. */
    extern NSString *const ATSurveyShownNotification;
    
    /** Notification sent when a survey is submitted by the user. */
    extern NSString *const ATSurveySentNotification;
    

    Finally, we are working some new features in this area. I will update this answer when those are available.