Below is a list of steps neccessary to hook-up your Android app with the proxi.cloud panel.

Remember to set-up your application in the panel before integrating the SDK into your app. Go to https://panel.proxi.cloud and generate an API key for your app.

You will need to have the jcenter artifactory in your list of repositories and declare the dependency to our sdk.

  dependencies {
      implementation 'cloud.proxi.sdk:cloud.proxi.sdk:2.1.2'
  }

Make sure that you are using the latest avaliable version on jcenter:

Manifest Permissions

ACCESS_FINE_LOCATION is required in your manifest for the majority of functions to work.

ACCESS_WIFI_STATE and CHANGE_WIFI_STATE are neccessary to take advantage of the WiFi triggers

BLUETOOTH and BLUETOOTH_ADMIN permissions are required for scanning beacons.

Important!

Starting from Android 6 (API level 23) the user needs to be asked explicitly for the location permission. More information on this page.

Integration

Enable the SDK in your Application’s onCreate() method.

public class ExampleApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ProxiCloudSdk.create(this, "API_KEY");
    }
}

Play services

Make sure that you compile in a correct version of Google play services (if you are not using them already) - this is required for geofencing and other subcomponents to work

  implementation 'com.google.android.gms:play-services-location:15.0.1'

Please instert this into your app manifest within the application tag

  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Add support for Advertising identifier

To obtain advertising id you will need to add the following reference, unless you already use play services ads.

  implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1'

Get advertising id and pass value to SDK. Obtaining advertising id must be performed on separate thread.


    final Executor executor = Executors.newSingleThreadExecutor();

    executor.execute(new Runnable() {
            @Override
            public void run() {
            try {
                final AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(context);
                if(info != null) {
                    ProxiCloudSdk.getInstance().setAdvertisingIdentifier(info.getId());
                }
            } catch (IOException e) {
                Log.e(TAG, "Could not fetch advertising id", e);
            } catch (GooglePlayServicesNotAvailableException e) {
                Log.e(TAG, "Could not fetch advertising id, Google Play Service not available", e);
            } catch (GooglePlayServicesRepairableException e) {
                Log.e(TAG, "Could not fetch advertising id, Google Play Service need repairing", e);
            } catch (Exception e) {
                Log.e(TAG, "Could not fetch advertising id", e);
            }
        }
    });

And of course, if you need to remove it, just call it with null.

  ProxiCloudSdk.getInstance().setAdvertisingIdentifier(null);

Notifications and actions

Notifications are handled internally by SDK. There are three types of possible actions as selected in the proximity panel. They define what happen on notification being opened and how app shoud handle the provided URL.

  • Notification
  • Website
  • InApp

All of these notifications can be enhanced with graphic content. Just upload image in push notification settings in the panel. upload image

Notification

Opening notification will start launch activity. For this actions url is not needed, but if set, it can be retrieved in activity with getIntent() method.

public class ExampleActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final Intent intent = getIntent();
        final Uri data = intent.getData();
    }
}
Website

Clicking notification will open provided url in a browser.

In App

Opening notification will start activity via deep link. To make it work you need to add intent filter for url in manifest within target activity tag.

Sample filter for url: example://cloud.proxi.test

<activity
    android:name="cloud.proxi.test.ExampleApp">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="example"
              android:host="cloud.proxi.test"/>
    </intent-filter>
</activity>

More information can be found on the Android Developer page

Notification customisation

If you require different look and feel of the notifications generated by the SDK, you can customize them through meta-data in your manifest. Below are shown all possible options, but you my choose to modify only some of them (or none).

<application>
    <!--set large icon for your notification, default is set to null -->
    <meta-data
        android:name="cloud.proxi.notification.large_icon"
        android:resource="@mipmap/your_large_icon" />

    <!-- set small icon, default is set to google material notification icon -->
    <meta-data
        android:name="cloud.proxi.notification.small_icon"
        android:resource="@drawable/your_small_icon" />

    <!--notification color, default is grey -->
    <meta-data
        android:name="cloud.proxi.notification.color"
        android:resource="@color/your_color" />
        
    <!--if set to true (default is false), thumbnail of image from graphic push will be shown in place of large icon for collapsed notification view--> 
    <meta-data
        android:name="cloud.proxi.notification.thumbnail_enabled"
        android:value="true" />

    <!-- Set your own notification channel. If not provided, default channel named "Geolocation Push Notifications" will be used -->
    <meta-data
        android:name="cloud.proxi.notification.channel_id"
        android:value="your_channel_id" />

</application>