logo
Frontend callback feature is released on May 14, 2022.

Introduction

Our SDK provides a callback after closing or submitting the survey by the user. In the below code, you will see how to implement a 1flow survey callback using Broadcast Receiver.
  1. Create Broadcast Receiver:
    1. JAVA
      java
      BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equalsIgnoreCase("survey_finished")){ String surveyDetail= intent.getStringExtra("surveyDetail"); //this will give you json data structure Log.v(tag,"Submitted survey data["+surveyDetail+"]"); } } };
      KOTLIN
      kotlin
      val broadCastReceiver = object : BroadcastReceiver() { override fun onReceive(contxt: Context?, intent: Intent?) { var surveyData: String? = "" when (intent?.action) { "survey_finished" -> { surveyData = intent.getStringExtra("surveyDetail").toString() Log.v(tag, "Survey Data:" + surveyData) } } } }
  1. Register Broadcast Receiver:
    1. JAVA
      java
      IntentFilter inf = new IntentFilter(); inf.addAction("survey_finished"); registerReceiver(broadcastReceiver , inf);
      KOTLIN
      kotlin
      val inf = IntentFilter() inf.addAction("survey_finished") registerReceiver(broadCastReceiver, inf)

Demo data structure 1flow callback:

json
Example:- { "survey_id": "XXXXXXXXXXXXX", "survey_name": "Rating Survey", "trigger_name": "fileSaved", "status": "finished", "screens": [ { "question_title": "How it worked", "question_type": "checkbox", "screen_id": "XXXXXXXXXXXXX", "question_ans": [ { "answer_value": "Option 1" }, { "answer_value": "Option 2" }, { "answer_value": "Other", "other_value": "Checkbox Other" } ] }, { "question_title": "Your valuable feedback", "question_type": "text", "screen_id": "XXXXXXXXXXXXX", "question_ans": [ { "answer_value": "This is user's feedback" } ] } ] }

Fields in 1flow callback:

survey_name: string
trigger_event_name: string
status: string
screens: Array