Erich
Erich

Reputation: 15

Sending push notifications to UrbanAirship test devices using java

I'm trying to use UrbanAirship Java API to send push notifications. In web control panel there is a field to setup a list of test devices and I'd like to send a push notification to devices in this list.

Which selector should I use in pushPayload.setAudience(...)?

PushPayload payload = PushPayload.newBuilder()
            .setAudience(Selectors.????()) // how to select test devices?
            .setNotification(Notifications.alert(message))
            .build();

Thanks!

Upvotes: 0

Views: 246

Answers (1)

mfd
mfd

Reputation: 58

Unfortunately, the API does not support a single test device selector. The purpose of the test devices list is to provide a shortcut for people that would like to push to test devices through the message composer, since (outside of test devices) the composer only allows the targeting of all devices, single devices, and segments.

To target test devices via the API, you must manually build up the audience using an or selector, e.g.,

// If your test device list had 3 iOS channels and 2 Android channels, you 
// would build your audience like this
Selector testDevices = Selectors.or(
    Selectors.iosChannels("ios-channel1", "ios-channel2", "ios-channel3"),
    Selectors.androidChannels("android-channel1", "android-channel2")
);

Upvotes: 1

Related Questions