-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel
committed
May 23, 2018
1 parent
505357f
commit ffb52e0
Showing
31 changed files
with
361 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
## Introduction | ||
|
||
The Placed SDK for Android is designed to help you add Placed location gathering to your app. It exposes simple public API calls that can be used to turn location gathering on. | ||
The Placed SDK for Android is designed to help you add Placed location gathering to your app. It exposes simple public API calls that can be used to turn on and off location gathering. | ||
|
||
The SDK has been designed for easy setup and integration with both new and existing mobile applications. | ||
|
||
|
@@ -16,10 +16,10 @@ Before you can integrate the Placed SDK into your app, you need to add the relev | |
|
||
1. Add the following to your **root** `build.gradle` file: | ||
|
||
``` | ||
```gradle | ||
allprojects { | ||
repositories { | ||
... | ||
// other repositories | ||
maven { url "https://raw.githubusercontent.com/placed/android-placed-sdk/master/repository" } | ||
} | ||
|
@@ -28,15 +28,15 @@ Before you can integrate the Placed SDK into your app, you need to add the relev | |
2. Add the following to your **app** `build.gradle` file: | ||
``` | ||
```gradle | ||
dependencies { | ||
// other dependencies go here... | ||
// Use the latest patch version of the Placed SDK | ||
// noinspection AndroidLintGradleDynamicVersion | ||
compile 'com.placed.client:android-persistent-sdk:4.0.+' | ||
// NOTE: If you use any Google Play services APIs above version | ||
// NOTE: If you use any Google Play services APIs above version | ||
// 10.0.1, add the following to avoid crashes caused by inconsistent | ||
// API versions. | ||
compile('com.google.android.gms:play-services-ads:<your-version>') { | ||
|
@@ -51,7 +51,7 @@ Before you can integrate the Placed SDK into your app, you need to add the relev | |
3. You may encounter Lint error: 'InvalidPackage: Package not included in Android' related to Okio and Retrofit. (This is a known issue with Okio that you can read about [here](https://github.com/square/okio/issues/58).) | ||
If so, create a `lint.xml` with the following contents: | ||
``` | ||
```xml | ||
<lint> | ||
<issue id="InvalidPackage"> | ||
<ignore regexp=".*okio.*" /> | ||
|
@@ -61,9 +61,10 @@ Before you can integrate the Placed SDK into your app, you need to add the relev | |
``` | ||
And reference it from your **app** `build.gradle` file: | ||
``` | ||
```gradle | ||
android { | ||
... | ||
// ... | ||
lintOptions { | ||
lintConfig file("lint.xml") | ||
} | ||
|
@@ -74,50 +75,53 @@ At this point your app should build, although the Placed SDK will not start yet. | |
### Second, integrate the Placed SDK | ||
Once you've added the Placed SDK as an app dependency, adding the Placed SDK to your app involves several more steps: | ||
Once you've added the Placed SDK as an app dependency, completing installation of the Placed SDK to your app involves a couple more steps: | ||
1. Add the Placed provided app key to AndroidManifest.xml | ||
2. Prompt for location permission | ||
3. Register the user for location collection by the Placed SDK. | ||
1. Prompt for location permission. | ||
2. Register the user with Placed SDK. | ||
#### AndroidManifest.xml changes | ||
#### Location Permission | ||
Add the application key provided to you by Placed in the application tag of your **AndroidManifest.xml**. | ||
As outlined in Section 5 of the [Placed Affiliate Agreement](https://affiliate.placed.com/placed-affiliate-agreement/), you must satisfy two requirements prior to registering a user with the Placed SDK: | ||
1. *Gather Express Consent for User Data Collection via Opt-in Dialog* | ||
In addition having a legally compliant privacy policy describing Placed’s collection of location and device information, you must include a discrete opt-in dialog which gathers express consent for data collection. This dialog appears prior to the fine location permission prompt, and includes: | ||
- The language: “*Aggregated device data, including location and apps, is measured for the purposes of market research by Placed, Inc.*” | ||
- Links to the Placed [Terms of Service](https://www.placed.com/terms-of-service) and [Privacy Policy](https://www.placed.com/privacy-policy) | ||
- Buttons to “Accept” or “Cancel” | ||
``` | ||
<meta-data android:name="placed_app_key" android:value="YOUR_APP_KEY" /> | ||
``` | ||
2. *Prompt for Fine Location Permission* | ||
Eligible users must allow fine location permission, which subsequently triggers app registration as described in the [Register a User](#register-a-user) section. | ||
#### Prompting for location permission | ||
For an example of the opt-in dialog and location permission prompt, please refer to the [main activity of the sample app](./SampleApp/app/src/main/java/com/placed/android/sampleapp/MainActivity.java). We have also provided a [gallery for inspiration](./gallery) on how you can better integrate the opt-in experience into your app. | ||
If you don't already prompt for fine location permission, you should do so before registering the user with the Placed SDK. | ||
#### Register a user | ||
For an example, see the [main activity in the sample app](https://github.com/placed/android-placed-sdk/blob/master/SampleApp/app/src/main/java/com/placed/android/sampleapp/MainActivity.java). | ||
Once you've prompted for location permission and gathered express consent to collect user data, you need to register your user with the Placed SDK. There are __two options__ when registering a user with the Placed SDK. | ||
Notice in this case the fine location permission is requested before registering the user and acceptance triggers app registion as described below. | ||
##### Option 1: Add your Placed app key to your AndroidManifest.xml | ||
### Registering a user | ||
Once you've prompted for fine location permission you need to register your user with the Placed SDK. | ||
```xml | ||
<meta-data android:name="placed_app_key" android:value="YOUR_APP_KEY" /> | ||
``` | ||
|
||
The following code snippet registers the user: | ||
And then call: | ||
|
||
```java | ||
PlacedAgent.registerUser(this); | ||
``` | ||
|
||
For an example, see the [main activity in the sample app](https://github.com/placed/android-placed-sdk/blob/master/SampleApp/app/src/main/java/com/placed/android/sampleapp/MainActivity.java). | ||
For an example, see the [main activity in the sample app](./SampleApp/app/src/main/java/com/placed/android/sampleapp/MainActivity.java). | ||
|
||
## How to join | ||
Please contact your Placed representative to find out how to register your account. If you do not have a representative yet, please email [[email protected]](mailto:[email protected]). | ||
##### Option 2: Add your Placed app key at runtime | ||
|
||
## Support | ||
For further guidance contact [[email protected]](mailto:[email protected]). | ||
All you have to do is call: | ||
|
||
## Reference | ||
```java | ||
PlacedAgent.registerUser(this, "YOUR_APP_KEY"); | ||
``` | ||
|
||
`static void registerUser(final Context context)` | ||
## How to join | ||
Please contact your Placed representative to find out how to register your account. If you do not have a representative yet, please email [[email protected]](mailto:[email protected]). | ||
|
||
This is the main method to register the user with the Placed SDK and begin | ||
location collection by the Placed SDK. If you have EULA or terms of service that the user is required to accept before tracking, | ||
call this method after the user accepts those terms. | ||
## Support | ||
For further guidance, please contact [[email protected]](mailto:[email protected]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
SampleApp/app/src/androidTest/java/com/placed/android/sampleapp/ApplicationTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
SampleApp/app/src/main/java/com/placed/android/sampleapp/SampleDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.placed.android.sampleapp; | ||
|
||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.view.View; | ||
import android.view.Window; | ||
|
||
enum SampleDialogAction { | ||
TERMS, PRIVACY, ACCEPT, CANCEL | ||
} | ||
|
||
public class SampleDialog extends Dialog { | ||
public interface SampleDialogListener { | ||
void onActionReceived(SampleDialogAction action); | ||
} | ||
|
||
public SampleDialogListener onActionListener; | ||
|
||
SampleDialog(@NonNull Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(R.layout.sample_dialog); | ||
|
||
setupButtons(); | ||
} | ||
|
||
private void setupButtons() { | ||
findViewById(R.id.btn_terms).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
onActionListener.onActionReceived(SampleDialogAction.TERMS); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btn_privacy).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
onActionListener.onActionReceived(SampleDialogAction.PRIVACY); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btn_accept).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
onActionListener.onActionReceived(SampleDialogAction.ACCEPT); | ||
dismiss(); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
onActionListener.onActionReceived(SampleDialogAction.CANCEL); | ||
dismiss(); | ||
} | ||
}); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
SampleApp/app/src/main/res/drawable-hdpi/rounded_corners_shape.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle" > | ||
|
||
<solid | ||
android:color="@color/sample_orange" > | ||
</solid> | ||
|
||
<corners | ||
android:radius="5dp" > | ||
</corners> | ||
|
||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.