Skip to content

usabilla/usabilla-u4a-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

GetFeedback Mobile SDK Unity Wrapper

Overview

Congratulations! You have build an application for Android or iOS using Unity, and You're ready to collect feedback from your users.

GetFeedbacks Unity Wrapper gives You the ability to collect feedback natively on Android or iOS. No extra code is needed to get the forms you've created displayed. GetFeedback handles all configuration and displaying across the different devices.

Drop the wrapper-code into your assets folder, add a few lines of code in your application, and start collecting.

Key Topics

The following topics will be covered in this readme

Installation

Get the latest code from our github repository. Unpack the zip file into your Unity project Assets/Plugins folder. Take care not to overwrite any other files

If Your application targets iOS, open the Usabilla.framework.meta file (auto-generated by Unity), and change the AddToEmbeddedBinaries: false to AddToEmbeddedBinaries: true. This ensures that the framework will be added correct in the iOS application.

Initialisation

To proper set up the GetFeedback SDK, call GetFeedback.Bridge.initialize("<YOUR APP ID>>"). This MUST be done before any campaign can be displayed. Your App ID is created when You create Your Campaign on the GetFeedback website

Show Feedback form

To show a FeedBack form, call GetFeedback.Bridge.showFeedback("<FORM ID>"). This will display the form, covering the current UI. NOTE: The SDK doesn't pause any threads or code. If it is needed to halt the current application execution, make sure to do so before calling the SDK

Show Campaign / Send Event

To show a FeedBack campaign, call GetFeedback.Bridge.sendEvent("<The Event>>"). This will depending on the parameters for the campaign, display a banner with the first page of the campaign. Once a campaign has been displayed on a device, it can not be displayed again on the device.

NOTE: The SDK doesn't pause any threads or code. If it is needed to halt the current application execution, make sure to do so before calling the SDK

Callback from SDK

The SDK can report back to the Unity Application when certain events occur, e.g. the Feedback form has been removed. Call GetFeedbackBridge.setDelegate() to enable callback. The SDK needs to know where to deliver the callback. Configure this with GetFeedback.Events.sdkEvent.AddListener(<function to call>). The sdkEvent is a UnityEvent<string> so the function should accept a string eg public void sdkCallBackMethod(string data). To learn about the data, check the

Configure Theme

The SDK allowas for some font and images customization. The Theme class, holds 4 properties. Configure the Theme object, and then use the

Bridge.setTheme() 

method the apply the theme. Note that the theme must be set before any call to showFeedBack or sendEvent. The setTheme only needs to occur once, unless there is a need for different themes throughout the application.

headerColor

(iOS only)  - must be a #rgb string (eg #97D3BC)

fonts

regular - specify the name of the font  NOT the filename   
textSize - size in px  
bold  - specify the name of the font  NOT the filename  
titleSize  - size in px
miniSize  - size in px. The minimum size of the fonts

The font-files must be placed in the StreamingAssets Directory. The SDK will search the library for any .ttf files and install them in the application, no further setup is need in the native app

images

enabledEmoticons - an array of strings of up to 5 images, used instead of the default emoticons
disabledEmoticons - an array of strings of up to 5 images, used instead of the default disabled emoticons

All Image for the Theme must also be placed in the StreamingAssets. The Native SDK will read the files from this directory.

banner (see Customize Campaign Banner)

If the banner is left empty, the default SDK banner implementation will be applied. To configure a different banner layout add a Banner Object

Customize Campaign Banner

The Banner object holds 4 properties

enableClickThrough

  a bool. Used to allow click-through in the view outside the card of the banner 

contourBgAssetName

  The name of the image used as background. The image will be scaled to fill the screen

logo

  A BannerLogo object, with one property
  assetName - the name of the logo
  The logo is constraint to 150x115 (HxW) in size

navigation

  A BannerNaviagtion  Object with 4 properteis 
  continueButtonBgAssetName - the name of the image used as background for the button (Optional)
  continueButtonTextColor - the text color as a #RGB string for the button (Optional)
  cancelButtonBgAssetName - the name of the image used as background for the button (Optional)
  cancelButtonTextColor - the text color as a #RGB string for the button (Optional)

Masking Personally Identifiable Information

The SDK has an option to mask (when data is submitted to the back-end) the data from input texts, specifically Text Input and Text Area. Please note that the email input field is not being masked.

It matches a list of RegEx and replaces them by the "X" character by default. To apply masking, create a DataMask object, populate it, and use the

    Bridge.setDataMasking(datamask);

method to apply the masking. See Appendix 2, for an example

To remove the previously set mask, call the method with an empty DataMask object

    DataMask mask = new DataMask();
    Bridge.setDataMasking(mask);

The SDK provides some default masking, where emails are masked, and any digit longer than 4 digits (e.g. credit-card numbers) To apply the default masking, call the method with null

   Bridge.setDataMasking(null);

DataMask

     A DataMask object with 2 properties
     maskCharacter - the masking character. If more than 1 charater is provideded, only the first is used
     masks - The RegEx strings that should be used to mask data 

Support

If you need help, want to report an issue, or have a question please reach out to the support team via our Help Center or email [email protected]

Appendix 1: Theme example

  Fonts font = new Fonts();
  font.regular = "DancingScript-Bold";
  font.textSize = 15;
  font.bold = "TBFvoice-Bold";
  font.titleSize = 15;
  font.miniSize = 12;

  Images images = new Images();
  images.enabledEmoticons = new string[] { "pouting.png", "weary.png", "neutral.png", "face.png", "smiling.png" };
  images.disabledEmoticons = new string[] { "pouting.png", "weary.png", "neutral.png", "face.png", "smiling.png" };

  BannerLogo logo = new BannerLogo();
  logo.assetName = "logo.png";

  BannerNavigation navigation = new BannerNavigation();
  navigation.continueButtonBgAssetName = "buttonContinue.png";
  navigation.continueButtonTextColor = "#FFFFFF";
  navigation.cancelButtonBgAssetName = "buttonCancel.png";
  navigation.cancelButtonTextColor = "#97D3BC";

  Banner banner = new Banner();
  banner.enableClickThrough = false;
  banner.contourBgAssetName = "background.png";
  banner.logo = logo;
  banner.navigation = navigation;

  Theme theme = new Theme();
  theme.fonts = font;
  theme.images = images;
  theme.banner = banner;
  theme.headerColor = "#345423";

Appendix 2: Masking example

Setting a mask

DataMask mask = DataMask();
mask.maskCharacter = "*";
mask.masks = new string[] { "[0-9]{4,}",  
      "[a - zA - Z0 - 9\\+\\.\\_\\%\\-\\+]{ 1, 256 }\\@[a - zA - Z0 - 9][a - zA - Z0 - 9\\-]{ 0,64} (\\.[a-zA - Z0 - 9][a-zA - Z0 - 9\\-]{ 0,25})+"};
Bridge.setDataMask(mask);

Reset masking

DataMask mask = DataMask();
Bridge.setDataMask(mask);

Set Default SDK masking

Bridge.setDataMask(null);