I've integrated Urban Airship SDK to my application on device with Android 4.2 (Jelly Bean). I've received general push-notifications. It's Ok. But I want to get interactive push-notification with button with "Save" label.
My dependencies from build.gradle
:
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:+'
compile project (':urbanairship-lib-6.1.1')
compile 'com.android.support:support-v4:22.2.0'
// Recommended for in-app messaging
compile 'com.android.support:cardview-v7:22.2.0'
// Recommended for location services
compile 'com.google.android.gms:play-services-location:7.5.0'
// Required for Android (GCM) push notifications
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile files('libs/commons-io-2.4.jar')
compile files('libs/FlurryAnalytics-4.1.0.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
}
According to official documentation, I've added the following code in the onCreate()
method in MyApplication
class:
@Override
public void onCreate() {
AirshipConfigOptions options = new AirshipConfigOptions();
options.developmentAppKey = "sdgsdgsdhsdh";
options.developmentAppSecret = "sdhsdhsdhsdhsh";
options.productionAppKey = "Your Production App Key";
options.productionAppSecret = "Your Production App Secret";
options.inProduction = false;
options.gcmSender = "11111111";
UAirship.takeOff(this, options);
NotificationActionButton hiButtonAction = new NotificationActionButton.Builder("btnSave")
.setLabel(R.string.save)
.setPerformsInForeground(true)
.build();
// Define the group
NotificationActionButtonGroup buttonGroup = new NotificationActionButtonGroup.Builder()
.addNotificationActionButton(hiButtonAction)
.build();
// Add the custom group
UAirship.shared().getPushManager().addNotificationActionButtonGroup("save", buttonGroup);
UAirship.shared().getPushManager().setUserNotificationsEnabled(true);
UAirship.shared().getPushManager().setPushEnabled(true);
}
After that I've tried test push from my Urban Airship account:
EDIT:
I've used Urban Airship API v3. According to official documentation I've sent push with json:
{
"audience": {
"named_user": "2971"
},
"device_types":["android"],
"notification": {
"android": {
"alert": "Hello",
"extra": {
"EEID": "2971",
"DATE": "20150601"
},
"interactive": {
"type": "save"
}
}
}
}
But I've received general push-notification with "Hello" text and without any buttons.
What could be the problem and how to open some activity by click on the button in notification?
Thanks in advance.