Previously we showed how to verify that the Plot plugin was integrated properly in an IOS app. This post shows how to verify the Android integration of the Plot plugin.

Test Receiving Of Notifications

Of course the most important feature of the Plot plugin is sending location based notifications. Just like in IOS, you can verify the Plot plugin is integrated properly by receiving a location based notification. The easiest way of doing that is adding a test notification at your current location. When you have received that notification, you can be sure that notifications can be received. It is advisable to create a separate account for testing purposes to prevent bothering your end users with these notifications. Creating an extra account just for testing purposes is free and can be done here.

Let’s start with creating a notification to test. You can create a notification in our dashboard. Login with the private token we have provided you. First create a place at your current position. Then add a notification and set the status of that notification to ‘published’.

Plot tries to update its database once every hour. This isn’t influenced by whether the app has been opened or closed in this period. Therefore, when a new notification has been added it may take up to one hour before that notification is downloaded and may be received by the user.
For testing purposes, you can trigger a database update by clearing the local database of your app on your phone. To clear the local database you have to open the Apps section under settings and find your app. There you can stop the app and clear local data. When the app is then opened again it will directly start downloading the notifications and, when you are at the right location of course, show the notifications.

When a notification has been received, it won’t be send again. Cleaning the local database will make it possible to receive a notification again. This can make testing easier.

Debug mode and log messages
You should turn off debug before submitting to app store by setting “debug”: false in your plotconfig.json

Plot provides log messages to help you diagnose situations where no notification is shown. It for example helps you distinguish between situations where Plot thinks it isn’t close enough to a location or whether the notification filter dropped the notification.

Since version 2.x, in order for Plot plugin to log these messages, you have to enable debug mode. That can be done by setting debug to true in plotconfig.json. Notice the last line of the following code snippet:

  "publicToken": "YOUR_TOKEN",
  "enableOnFirstRun": true,
  "debug": true

The messages are then sent to LogCat. Most IDEs have the possibility to show these messages directly from there.

When enabling Plot you should see the following log message:

10-04 10:53:27.362 5834-6480/ D/Plot/SettingsService: Enabling Plot plugin.

After Plot is enabled, it will download the notifications from the server. This should happen once per hour. It shows the total number of notifications and the notifications that have been loaded. You can use this message to ensure the right notifications are loaded.

10-04 10:53:34.673 5834-6480/ D/Plot/BasicNotificationService: Received 39 notifications.
10-04 10:53:36.411 5834-6480/ D/Plot/BasicNotificationService: Loaded Notification{id='9f82ae0ad3b94a498bdbfb9f163d75a4', location=Location{latitude=52.373150255778086, longitude=4.905467582617121}, message='...', timespans=[], data='...', matchRange='4520', triggerOnExit='false', dwellingMinutes='0', cooldownGroups=[Cooldown{cooldownSeconds=1, groupName='9f82ae0ad3b94a498bdbfb9f163d75a4'}], landingPageNotification='false', geotrigger='false', isAppLinkNotification='false', segmentationIds='[]', segmentationProperties='[]'}

Once the notifications are loaded, then Plot can match these notifications. It shows the notifications that were considered and the distance to these notifications in meters. When the distance is smaller than the match range, then a notification “matches” and will be sent to the notification filter (if you have one defined). Checking the distance for the notifications should happen at least once every 10 minutes.

10-04 10:53:36.590 5834-6480/ D/Plot/GeofenceMatching: Checking for geofence matches.
10-04 10:53:36.693 5834-6480/ D/Plot/GeofenceMatching: Distance to 37939d977fa744339bcfbb1de5833b37;cbf373cfa41248ee837799099f5c99c0: 43 (match range: 200)

When there are one or more notifications sent to the notification filter, then you should see the following three lines. First the number of matching notifications, followed by details about these notifications. When you don’t have a notification filter, then this step is skipped.

10-04 10:53:37.569 5834-6643/ D/Plot/NotificationFilterUtil: Received 1 notifications for filtering
10-04 10:53:37.578 5834-6643/ D/Plot/NotificationFilterUtil: FilterableNotification(id = 471b01eb41af436f9cb38196936a727c;41b1ce9a9f2140ce9512f03b4fafc04b, matchId = 82086267-d4b1-4eea-972c-95a841ffb3a2, message = 15/9 13:55 test quicksync, data = , notification = null, trigger = enter)

When the notification filter is completed, then the following log message appears. It shows how many notifications passed through the notification filter and then shows these notifications. These notifications should then appear in the notification area.

10-04 10:53:37.669 5834-6643/ D/Plot/NotificationFilterUtil: 1 notifications passed
10-04 10:53:37.674 5834-6643/ D/Plot/NotificationFilterUtil: FilterableNotification(id = 471b01eb41af436f9cb38196936a727c;41b1ce9a9f2140ce9512f03b4fafc04b, matchId = 82086267-d4b1-4eea-972c-95a841ffb3a2, message = Wednesday: 15/9 13:55 test quicksync, data = , notification = null, trigger = enter)
Location testing using emulator
Setting emulatorTesting to true will increase the battery usage significantly. Make sure you disable it before submitting to app store.

Starting from version 2.4, Plot plugin supports two ways of location testing. Testing on emulator and setting a test location using Plot.testLocaiton() method.

In order to test on an emulator, you need to set the following properties in plotconfig.json file:

"debug": true,
"emulatorTesting": true

Emulator testing is only enabled when debug is set to true. Otherwise, it is going to be ignored.

After setting the previous properties, you can use Android emulator location settings to change your location. To access the location first you need to click on the three dots as shown in the following picture:

The next step is to set the testing location as shown in the following picture. The part within the red rectangle is where you can set the test location.

Location testing using testLocation() method

It is also possible to change the location for testing purpose programmatically. In order to achieve that, we added the following method:

Plot.testLocation() which takes either a combination of latitude and longitude, or a Location object. TODO: add link to Javadocs of testLocation method

Changing location using the testLocation method is only available in debug mode. You need to set

"debug": true

in plotconfig.json before you can use that method. You also need to call it, after Plot plugin is initialized.

Wrap up

Testing your Android integration isn’t hard. We have shown you how you can verify that your app can successfully receive notifications and what to make of the log messages Plot may print. Don’t forget to disable the debug log messages when releasing your application.

We hope that this blogpost made it clearer how to properly integrate the Plot plugin into your Android application. If you have problems during one of these steps, we monitor Stackoverflow, where you can post your question. It is also possible to contact your customer success manager with questions. We will then help you the best we can.