Tôi đã tích hợp Urban Airship SDK vào ứng dụng của mình trên thiết bị với Android 4.2 (Jelly Bean). Tôi đã nhận được thông báo đẩy chung. Được rồi. Nhưng tôi muốn nhận thông báo đẩy tương tác bằng nút "Lưu".Làm thế nào để có được thông báo tương tác đẩy với Urban Airship trong Android?
phụ thuộc của tôi từ 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')
}
Theo official documentation, tôi đã thêm đoạn mã sau trong phương pháp onCreate()
trong MyApplication
lớp:
@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);
}
Sau đó tôi đã cố gắng thử nghiệm push từ tài khoản Urban Airship của tôi:
EDIT:
Tôi đã sử dụng API Airship đô thị v3. Theo official documentation Tôi đã gửi push với json:
{
"audience": {
"named_user": "2971"
},
"device_types":["android"],
"notification": {
"android": {
"alert": "Hello",
"extra": {
"EEID": "2971",
"DATE": "20150601"
},
"interactive": {
"type": "save"
}
}
}
}
Nhưng tôi đã nhận được tổng push thông báo với "Hello" text và không có bất kỳ nút.
Điều gì có thể gây ra sự cố và cách mở một số hoạt động bằng cách nhấp vào nút trong thông báo?
Xin cảm ơn trước.
Nếu tôi nhớ chính xác, nhà soạn nhạc "thử nghiệm đẩy" không có khả năng gửi thông báo tương tác. Bạn sẽ cần phải gửi thông báo thông qua các nhà soạn nhạc đẩy bình thường. Hoặc chỉ cần gửi thông qua API như được ghi ở đây: http://docs.urbanairship.com/api/ua.html#interactive-notifications – dperconti
Cuối cùng tôi đã tìm thấy câu trả lời. Tôi không nhìn thấy nút này "Lưu" trong thông báo của tôi vì tôi có điện thoại kết nối với PC qua USB. http://stackoverflow.com/a/18477621/1225669 – anivaler
Chà, vấn đề thú vị. Nó có hiển thị nếu bạn cố mở rộng thông báo theo cách thủ công không? – ralepinski