Skip to content

Commit

Permalink
Merge pull request #94 from SurveyMonkey/release-v3.0.1
Browse files Browse the repository at this point in the history
Release v3.0.1
  • Loading branch information
winimeow authored Mar 23, 2023
2 parents 055def2 + 81ece87 commit 9ce6704
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 3.0.1
- App updated to AndroidX
- Added kotlin co-routines and Retrofit
69 changes: 41 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,69 @@ Want to improve your product and app store ratings? The SurveyMonkey Mobile Feed
### Steps To Integrate

#### Step 1: Download Mobile SDK
Download the [latest release](https://github.com/SurveyMonkey/surveymonkey-android-sdk/releases) or clone the SDK.
```bash
git clone https://github.com/SurveyMonkey/surveymonkey-android-sdk.git

Gradle (mavenCentral):
```groovy
implementation 'com.surveymonkey:surveymonkey-android-sdk:3.0.1'
```
**OR**
or

Install via Maven (jCenter):
Install via Maven (mavenCentral):
```xml
<dependency>
<groupId>com.surveymonkey</groupId>
<artifactId>surveymonkey-android-sdk</artifactId>
<version>2.0.0</version>
<type>pom</type>
<groupId>com.surveymonkey</groupId>
<artifactId>surveymonkey-android-sdk</artifactId>
<version>3.0.1</version>
</dependency>
```
or Gradle (jCenter):
```

**OR**

Download the [latest release](https://github.com/SurveyMonkey/surveymonkey-android-sdk/releases)

**Importing to Android Studio**

1. From the menu bar, click **File -> Project Structure -> Dependencies -> JAR/AAR dependency**
2. Provide a path to the **surveymonkey_android_sdk.aar** directory that is contained in the **surveymonkeyandroidsdk** repo
3. Select the **surveymonkey_android_sdk.aar** file
4. In your **AndroidManifest.xml** file, make sure you\'ve included the `<uses-permission android:name="android.permission.INTERNET"/>` permission
5. Add following dependencies to your **build.gradle** file
```groovy
implementation 'com.surveymonkey:surveymonkey-android-sdk:2.0.0'
```
implementation "com.squareup.retrofit2:retrofit:$latestversion"
implementation "com.squareup.retrofit2:converter-gson:$latestversion"
implementation "com.squareup.okhttp3:logging-interceptor:$latestversion"
implementation "com.squareup.retrofit2:converter-scalars:$latestversion"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$latestversion"
```
6. Make sure your **build.gradle** file has `implementation project(':surveymonkey_android_sdk')` under `dependencies {}`


#### Step 2: Set up your SDK Collector
You must create your survey and set up your SDK Collector in [www.surveymonkey.com](https://www.surveymonkey.com).

1. Once you create your survey, navigate to the **Collect** tab and select **+New Collector > SDK** from the menu on the righthand side
2. Click **Generate**. The code you generate is your **Survey Hash**, you'll **Copy** this and use it to point the SDK to your survey in the steps below
<img alt="sdk_collector" src="https://user-images.githubusercontent.com/119406475/227167584-a52bf4b4-1531-4cc7-8fe6-f052d01d2c05.png">

<img src=https://raw.githubusercontent.com/SurveyMonkey/surveymonkey-android-sdk/master/images/sdk_collector.png />

### Step 3: Importing to Android Studio

1. From the menu bar, click **File -> New Module -> Import .JAR or .AAR package**
2. Navigate to the **surveymonkeyandroidsdk** directory that is contained in the **surveymonkeyandroidsdk** repo
3. Select the **surveymonkey-android-sdk.aar** file and click Finish
4. In your **AndroidManifest.xml** file, make sure you've included the `<uses-permission android:name="android.permission.INTERNET"/>` permission
5. Make sure your **build.gradle** file has `compile project(':surveymonkey_android_sdk')` under `dependencies {}`

### Step 4: Integrate the SurveyMonkey SDK with your app
### Step 3: Integrate the SurveyMonkey SDK with your app

1. Import the SDK
`import com.surveymonkey.surveymonkeyandroidsdk.SurveyMonkey;` and (for error handling)
`import com.surveymonkey.surveymonkeyandroidsdk.utils.SMError;`
`import com.surveymonkey.surveymonkeyandroidsdk.SurveyMonkey;` and (for error handling)
`import com.surveymonkey.surveymonkeyandroidsdk.utils.SMError;`
2. Initialize the SDK: `private SurveyMonkey sdkInstance = new SurveyMonkey();`

##### Important consideration
SurveyMonkey Android SDK requires androidx.appcompat.app.AppCompatActivity context .
For ex-
```java
sdkInstance.onStart(appCompatActivityContext, [SAMPLE_APP_NAME], [SAMPLE_REQUEST_CODE], [SAMPLE_SURVEY_HASH], [SAMPLE_CUSTOM_VARIABLES_DICTIONARY]);
```
The SurveyMonkey Feedback SDK makes use of the `startActivityForResult(Intent, int)` method lifecycle - thus, if you want to consume the respondent data returned by our SDK, you'll need to implement `onActivityResult()` in whichever activity you present surveys from.

The survey respondent data is returned as JSON. To parse it, implement the following in your `onActivityResult()`:
```java
String respondent = intent.getStringExtra("smRespondent");
JSONObject surveyResponse = new JSONObject(respondent);
JSONObject surveyResponse = new JSONObject(respondent);
```

If `resultCode != RESULT_OK` in your `onActivityResult`, an error has occurred. To obtain and parse the error into an SMError object, call:
Expand Down Expand Up @@ -160,4 +173,4 @@ We recommend creating multiple [surveys](http://help.surveymonkey.com/articles/e

*What is the minimum Android version supported?

As of version 2.0.0, the minsdk for this library is Api 21 (Android 5.x)
As of version 3.0.1, the minsdk for this library is Api 21 (Android 5.x)
19 changes: 11 additions & 8 deletions SimpleSurvey/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 33
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.surveymonkey.simplesurvey"
minSdkVersion 9
targetSdkVersion 23
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -20,8 +20,11 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.surveymonkey:surveymonkey-android-sdk:1.0.5'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.fragment:fragment:1.5.5'
implementation 'androidx.appcompat:appcompat:1.6.1'
testImplementation 'junit:junit:4.12'

implementation 'com.surveymonkey:surveymonkey-android-sdk:3.0.1'
implementation 'com.google.android.material:material:1.8.0'
}
5 changes: 3 additions & 2 deletions SimpleSurvey/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.surveymonkey.surveymonkeyandroidsdkexample">
package="com.surveymonkey.simplesurvey">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand All @@ -11,7 +11,8 @@
android:theme="@style/AppTheme">
<activity
android:name=".SimpleActivity"
android:label="Simple Activity">
android:label="Simple Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.surveymonkey.surveymonkeyandroidsdkexample;
package com.surveymonkey.simplesurvey;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.surveymonkey.surveymonkeyandroidsdk.SurveyMonkey;
import com.surveymonkey.surveymonkeyandroidsdk.utils.SMError;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class SimpleActivity extends Activity {
public class SimpleActivity extends AppCompatActivity {

public static final int SM_REQUEST_CODE = 0;
public static final String SM_RESPONDENT = "smRespondent";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.surveymonkey.surveymonkeyandroidsdkexample;
package com.surveymonkey.simplesurvey;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.Toast;

import androidx.fragment.app.FragmentActivity;

import com.surveymonkey.surveymonkeyandroidsdk.SMFeedbackFragment;
import com.surveymonkey.surveymonkeyandroidsdk.SMFeedbackFragmentListener;
import com.surveymonkey.surveymonkeyandroidsdk.SurveyMonkey;
Expand Down
8 changes: 5 additions & 3 deletions SimpleSurvey/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.android.tools.build:gradle:7.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -14,7 +15,8 @@ buildscript {

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}

Expand Down
4 changes: 3 additions & 1 deletion SimpleSurvey/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true

android.useAndroidX=true
2 changes: 1 addition & 1 deletion SimpleSurvey/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
Binary file removed images/sdk_collector.png
Binary file not shown.
Binary file removed surveymonkey_android_sdk.aar
Binary file not shown.

0 comments on commit 9ce6704

Please sign in to comment.