Installing UserReport SDK to iOS application

Introduction

If you have native iOS application written in Objective-C or Swift you can measure user satisfaction using UserReport survey tool. As pre-requisite, your account should be migrated to network-centric. Please contact support@userreport.com to perform a migration.

Unlike web-environment, the in-app environment does not allow to deploy tags that will allow rendering survey invitation. Therefore, some code modification is required to invite users to survey.

This instruction covers implementation of UserReport in your application. UserReport SDK targets iOS 9.0+ and requires Xcode 9.0+

Adding UseReport SDK

UserReport iOS SDK can be installed in various ways.

CocoaPods

CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'UserReport'
    
  2. Run pod install and open the .xcworkspace file to launch Xcode.

  3. Import the UserReport framework.

    import UserReport
    

Manually

To install it manually drag the UserReport project into your app project in Xcode or add it as a git submodule. In your project folder enter:

$ git submodule add git@github.com:AudienceProject/userreport-ios-sdk.git

Usage

Configure

Configure UserReport iOS SDK via SAK_ID, MEDIA_ID (You can find these values on media setting page) and information about user, if your application supports authentication.

Providing user login information allows respecting user's choice to not take part in a survey and anonymously track users demographic data across different apps. If an application does not support authentication, IDFA will be used.

// Create user object
let user = User()
user.email = "example@email.com" // UserReport SDK will hash email itself, raw e-mail will not be sent.

// You can also specify a email hash
user.emailMd5 = "MD5_EMAIL_HASH"
user.emailSha1 = "SHA1_EMAIL_HASH"
user.emailSha256 = "SHA256_EMAIL_HASH"

// Provide additional social network information
user.facebookId = "FACEBOOK_ID"

// Configure
UserReport.configure(sakId: "YOUR_SAK_ID", mediaId: "YOU_MEDIA_ID", user: user)

Screen tracking

Screen tracking important part of UserReport - invitations are shown based on a number of screen-views and also Screen-views are measured for Kits. Unlike web where pageview is clearly defined, screen-view should be tracked separately in native apps. There is two possibilities in SDK - choose what works better for your app.

Manual

To manually measure the screen view, use the method trackScreen().

class ViewController: UIViewController {
	override open func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        // Tracking screen view
        UserReport.shared?.trackScreen()
    }
}

Automatic

If you want to automatically measure views as screens using the UserReportViewController class.

class ViewController: UserReportViewController {
	...
}

Display mode

The survey can appear in two ways:

  • .alert - show survey like an alert view (Default)
  • .fullScreen - show survey in full screen mode, like the modal view controller

To change the display mode, please specify following:

UserReport.shared?.displayMode = .fullscreen

Change settings

To update the default rules for appear the survey use follow:

let settings = Settings()
settings.sessionScreensView = 5
settings.inviteAfterNSecondsInApp = 20

UserReport.shared?.updateSettings(settings)

Mute

In order for the survey not to be appear on important screens, you can use a variable mute.

UserReport.shared?.mute = true

Don't forget to return back to false.

Update user info

When changing user data, you should also send the updated data to the UserRecord iOS SDK.

let user = User()
user.email = "new_example@email.com"

UserReport.shared?.updateUser(user)

Session info

UserReport SDK stores the data on the count of screens viewed and the time the application is used. If necessary, you can get this data from a variable session. The session contains the following values:

  • screenView - number of screen viewed in current session
  • totalScreenView - number of screen viewed in all session
  • sessionSeconds - number of seconds spent in the application for current session
  • totalSecondsInApp - number of seconds spent in the application for all time
  • localQuarantineDays - number of days through which the survey will be appear again
  • settings - current settings for appear the survey
// Session information about the running time of the application and screen views
let session = UserReport.shared?.session

// Get current settings for appear survey
let currentSetting = session?.settings

Manually

If you decide to show the survey yourself, then you can use the following method:

UserReport.shared?.tryInvite()

Attachments

Comments

Powered by Zendesk