Targeting Based on FIP county Code

We are having difficulties reaching our devices via a county alias.  The implementation is an existing Urban Airship app that that will be addressed in a new way.  We are attempting to contact a group of devices by the fips_6-4 alias and feeding it in a 5 digit code.  The format of the request is:

 

{ "audience": { "or": [ { "location": { "fips_6-4": "<5 digit county code>", "date": { "recent": { "hours": 24 } } } }, { "location": { "fips_6-4": "<5 digit county code>", "date": { "recent": { "hours": 24 } } } } ] }, "notification": { "alert": "blah blah blah message." }, "device_types": [ "ios", "android" ] }

 

To which I am getting back

 

{"ok":true,"operation_id":"fed235d8-a58f-459c-8644-b356c627dea2","push_ids":["fb4ae1aa-3d5e-4de7-a1e7-9ae22312c173"],"message_ids":[],"content_urls":[]}

 

Note that there are no messages in the ids array. 

 

Our client library is using v 6.2, and is proven to receive singly targeted messages.  As an added control I attempted to send a segment targeted message from the portal, which also did not send to the device.    At this point it is unclear what is not correctly configured. My guess is something on the client end

 

My questions are: 

Is there a version dependence for these types of location message?

Is our account enabled to send these location targeted messages(does it matter)?

Is there any additional client initialization needed to target them(what specifically is needed)?

Is my format above correct for the request to reach the entire county?

Thanks in advance.

Didn't find what you were looking for?

New post

Comments

4 comments

  • Hi,

     

    Great post!

     

    If there are no message_ids, don't worry, that doesn't mean nothing is being sent. The message_ids field is related to our Rich Message feature. Let’s go through your questions one by one:

    Is there a version dependence for these types of location message?

    • If you are using SDK version 6.2 you will be able to send a push to a location, provided the mobile app has been setup for this.

    Is our account enabled to send these location targeted messages(does it matter)?

    • You do have access to send location targeted messages. The API will return an error if you try to a use a feature that you don't have access to.

    Is there any additional client initialization needed to target them(what specifically is needed)?

    Is my format above correct for the request to reach the entire county?

    • Yes, the query looks fine. You will be able to see some detailed locational data by searching for the county in the API, try something like this:

     

    curl https://go.urbanairship.com/api/location/\?q\=Baltimore\&type\=county -X GET -u "[***YOUR AUTHORISATION STRING***]" -H "Content-Type: application/json"

     

    So, now I would suggest that you do two things:

    • Check that the Urban Airship SDK is correctly setup so that the app is sending location updates. If you are running the app from Android Studio or Xcode then you will see something along the lines of "Received location update: Location <Your Location>" when a location update is sent. The best place to start for setting this up is the documentation on iOS Location Targeting and Android Location Targeting.

    • If that all seems to be working, test sending to a location that you are sure has a device that has triggered a location update within the timeframe you have specified i.e. your test device in your location.

     

    I hope this helps, I would be happy to answer any further questions.

    Comment actions Permalink
    0
  • Thank you for the info, I will take a closer look at the client configuration.  I have tried enabling location updates, but don't recall seeing that location log output.  Perhaps there is something I missed there.

    Comment actions Permalink
    0
  • It's possible that Location Updates aren't being triggered. Once location updates are enabled the app needs to be triggering either Continuous Location Updates or Single Location Requests.

    Comment actions Permalink
    0
  • So I went back to the client code and tried some stuff again.  I tried adding all of the following to my init:

           LocationRequestOptions locoptions = new LocationRequestOptions.Builder()
    .setPriority(LocationRequestOptions.PRIORITY_BALANCED_POWER_ACCURACY)
    .setMinDistance(800)
    .setMinTime(5, TimeUnit.MINUTES)
    .create();

    // Create a listener
    LocationListener listener = new LocationListener() {
    @Override
    public void onLocationChanged(Location location) {
    Log.i("UALib", "New user location " + location);
    }
    };

    // Add the listener to UALocationManager
    UAirship.shared().getLocationManager().addLocationListener(listener);
    // Set the default continuous location request options
    UAirship.shared().getLocationManager().setLocationRequestOptions(locoptions);

    // Enable location updates
    UAirship.shared().getLocationManager().setLocationUpdatesEnabled(true);

    // Allow location updates to continue in the background
    UAirship.shared().getLocationManager().setBackgroundLocationAllowed(true);

     

    I did not receive a location update with this code.  Finally I tried 

    UAirship.shared().getLocationManager().requestSingleLocation(locoptions);

    This resulted in the log output you mentioned, and a successful push message.

    So there is definitely something not quite working here, the code that did not work should have worked, and requesting just a single location is not ideal.  

    I am not sure if its relevant but I do see an exception :

    03-21 12:16:51.651 4810-5272/com.redacted W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.ClipData.getItemCount()' on a null object reference
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at android.os.Parcel.readException(Parcel.java:1626)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at android.os.Parcel.readException(Parcel.java:1573)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at android.content.IClipboard$Stub$Proxy.getPrimaryClip(IClipboard.java:197)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at android.content.ClipboardManager.getPrimaryClip(ClipboardManager.java:236)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at com.urbanairship.ChannelCapture$ClipboardHoneyComb.getText(ChannelCapture.java:340)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at com.urbanairship.ChannelCapture.checkClipboard(ChannelCapture.java:165)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at com.urbanairship.ChannelCapture.access$000(ChannelCapture.java:66)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at com.urbanairship.ChannelCapture$1$1.run(ChannelCapture.java:121)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    03-21 12:16:51.661 4810-5272/com.redacted W/System.err: at java.lang.Thread.run(Thread.java:818)

    Which seems internal to Urban AIrship.

    Thanks

     

    Comment actions Permalink
    0

Please sign in to leave a comment.