Create a feedback channel inside your customer app

0
59

Introduction

A simple way to implement powerful feedback surveys in mobile applications

Background

I am working ona mobile app that allows end consumers to provide feedback for market researchers and customer experience professional who run consumer focused research programmes.

The SDK isn’t about isn’t like app-reviews or web-reply feedback that rates the app’s look and feel or design. My solution allows consumers to rate their experience and or anteraction with an organisation through their consumer app. Once more using some of the feedback App’s functionlity such as geolocation, organisations can push a request for feedback following a consumer’s visit to a store, coffee outlet or use of a boarding pass.

My SDK also takes advantage of the mobile device’s capabilities allowing consumers to send voice and video feedback.

Essentially consomuers can take surveys in the already downloaded customer app and the results are sent back to a central service for easy analysis. Not only that the survey scripting capability is completely unlimited, something are unlikely to find anywhere else.

Using the code

Get Your OnePoint Global Developer’s Account

To run a survey, you will need a free OnePoint Global Developer’s Account and the SDK. Just fill in the registration form and you will receive your account.

http://www.onepointglobal.com/MobileSurveys/SurveyPlatform/createGlobalAccount

Installing the SDK

You can download the SDK and my sample App from GitHub. The SDK contains “lib”, “include” and “OPGResourceBundle” folders. “lib” ctaonins OnePoint Globa library SDK. “Include” contains library header files. “OPG ResourceBundle” contains associated resources for the SDK.

Copy “lib”, “include” and “OPGResourceBundle” to the source root of your project, where you need to integrate the OnePoint Global SDK.

To add the necessary framework complete the following steps:

  1. Open the .xcodeproj file. Click the project navigator and select the project. Click on Build Phaes -> Link Binary with Libraries. Click on ‘+’ ad then ‘Add other’. This will open the project structure in finder.
  2. Select ‘libOPGSDKV1.4.a’ from the ‘lib’ folder.
  3. Add the following supporting frameworks into the project:
  • libiconv.tbd
  • libz.tbd
  • libc++.tbd
  • libsqlite3.tbd

Adding Additional Build Settings

Add the -ObjC and -lz flag to the Other Linker Flags to load all the classes when using Categories. To do so, complete the following steps: 

  1. Open your project in Xcode.
  2. Select Application Target > Build Settings.
  3. In the Search field, search for ‘Other Linker Flags’.
  4. Add the -ObjC flag.
  5. Add the -lz flag.

Add  $SOURCE_ROOT/include flag to the Header Search Path to load all the headers of SDK and select “recursive” from the drop down.

Note: Selection of recursive is mandatory, otherwise header files missing errors will be generated

Creating Bridging Headers for Swift (if not created)

  1. Create a Bridging Header in project with name “(PROJECT_NAME)-Bridging-Header”. 
  2. Open Application Target and click Build Settings. Add  $(SRCROOT)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h  into the Objective-C Bridging Header in Build Settings. 
  3. Open the bridging header file and import the following files from SDK:
<code>#import "OPGSDK.h"</code>
<code>#import "OPGSurvey.h"</code>
<code>#import "OPGViewController.h"</code>

Add OPGResource Bundle

Select “OPGResourceBundle.bundle” file from OPGSDK downloaded bundle folder. Add it to the project to which you’re working on. Select current working project as the Target. Go to the Build Phases of project and make sure OPGResource Bundle available in “Copy Bundle Resources”. 

Note: It is mandatory to import this bundle file into project as it is required to take a survey.

iOS 10 Permissions:

iOS 10 now requires user permission to access Media Library, Photos, Camera and other hardware like these.

Please add the below 3 keys in info.plist of your project so that you can take media related questions in the survey with no error.

<code><key>NSCameraUsageDescription</key></code>
<code><string>This app needs access to the camera to take photos.</string></code>
<code><key>NSPhotoLibraryUsageDescription</key></code>
<code><string>This app needs access to photos.</string></code>
<code><key>NSMicrophoneUsageDescription</key></code>
<code><string>This app needs access to Microphone.</string></code>

Integrating Your First Survey

Initialize the SDK using Admin Username and SDK Key:  

Call initialize class method of OPGSDK with your admin Username and SDK Shared Key.

  • Goto Appdelegate.h of your project and add the following:
<code>#import <OPGSDK/OPGSDK.h></code>
  • Then in didFinishLaunchingWithOptions initialise the sdk with Username and provided.

Objective-C:

<code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions</code>
<code>{ </code>
<code>
<code>[OPGSDK initializeWithUserName:@"YOUR_ADMIN_NAME" withSDKKey:@"YOUR_ADMIN_KEY"];</code>
<code>
<code>return YES;</code>
<code>}</code>

Swift:

<code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {</code>
<code>
<code> OPGSDK.initialize(withUserName:"YOUR_ADMIN_NAME", withSDKKey: "YOUR_ADMIN_KEY")
</code>
<code> return true</code>
<code> }</code>

Integrate and Run a simple survey:

GetSurveyList:

Call getSurveyList() which provides the list of OPGSurvey objects for the particular admin account. Get the SurveyReference property from each OPGSurvey which is used to run the survey.

Objective-C:

<code><font size="3">OPGSDK* sdk = [OPGSDK new]; 
<font size="3"><code> </code> <code>NSError *error;</code></font>
<font size="3"><code> </code> <code>NSArray *surveyList = [sdk getSurveyList:&error]; 

Swift:

<code><font size="3">let sdk = OPGSDK() 
<font size="3"><code>do {</code></font>
<code><font size="3"> var surveyList: Array<OPGSurvey> = try sdk.getSurveyList() as Array 
<font size="3"><code> </code> <code>}</code></font>
<font size="3"><code> </code> <code>catch{</code></font>
<code><font size="3"> print("Survey not available") </font></code>
<code><font size="3"> }</font></code>
  • This method returns the list of all the surveys by taking input parameters NSError respectively. NSArray{objects of OPGSurvey}.This array has objects of OPGSurvey class. 
  • After getting the survey list goto “Taking the Survey:” section, to take the survey.

OPGSurvey Model Class:

The properties in the class are as follows:

  1. boolean IsGeoFencing;

  2. String Name;

  3. String Description;

  4. String ScriptID;

  5. String LastUpdatedDate;

  6. boolean IsOffline;

  7. String SurveyReference

The surveyReference of OPGSurvey should passed to loadSurvey method of OPGActivity which is explained in later sections

Taking the Survey

Integrating OPGViewController

OPGViewController is the viewcontroller class which is used to run the Survey. 

Hope you’ve created a tableview(or something else to display the surveys list) with the array of OPGSurvey class which you’ve got from “getSurveyList” api. Based on selection of row, we get the SurveyReference of survey selected.

Create a ViewController with “OPGViewController” as a superclass where the user can take a survey. 

To run the survey you need to call loadsurvey() in viewdidload().

Objective-C:

<code>[self loadSurvey:@"SURVEY_REFERENCE"]; 

Swift:

<code>self.loadSurvey("SURVEY_REFERENCE") </code> <code>

OPGViewController

OPGViewController class has a delegate that implements the Survey delegates.

Inherit OPGSurveyDelegate delegate methods from OPGViewController, so the methods can be used in the ViewController. In viewDidLoad: assign this delegate to ViewController.

Objective-C:

<code>self.surveyDelegate = self;</code>

OPGSurveyDelegate:

OPGSurveyDelegate is used to notify the state of the survey such as survey question start load , survey question finish load and survey completed.

OPGSurveydelegate Methods:

<code>-(void)didSurveyCompleted;</code>
<code>-(void)didSurveyFinishLoad;</code>
<code>-(void)didSurveyStartLoad;</code>

-(void)didSurveyCompleted

This delegate method returns callback once the whole survey has been completed.  You can perform the ViewController pop operations in this method.

-(void)didSurveyStartLoad

This delegate method returns callback once each question of the survey start loading. In order to engage the UI, user can also perform other operations like adding Activity Indicator, progress etc.

-(void) didSurveyFinishLoad

This delegate method returns callback when each question of the survey finish loading. 

History

Original Version

LEAVE A REPLY