Я использую Urban Airship для отправки Push -уведомления в мое приложение для Android. Я отправляю контент JSON с моего бэкэнд -сервера в качестве Push Content < /p>
push работает правильно, и я могу получить контент Push. Push Message также отображается в панели уведомлений устройства. Мне нужно настроить его и показать читаемому человеческому сообщению.@Override
protected void onPushReceived(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "Received push notification. Alert: " + message.getAlert() + ". Notification ID: " + notificationId);
String data = message.getAlert();
try {
JSONObject dataObj = new JSONObject( data );
Logger.info("Data obj " + dataObj.toString());
JsonDecoders.decodePushMessage(dataObj); // method to decode the json content
} catch (JSONException e) {
e.printStackTrace();
}
// try to build a new notification message.
Intent intent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.mipmap.ic_launcher)
.setTicker("Ticker")
.setContentTitle("Title")
.setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
.setContentIntent(contentIntent)
.setContentInfo("some info");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, b.build());
}
< /code>
Я могу декодировать контент push. < /p>
Я попытался добавить уведомление через NotificationManager, но затем показывает два уведомления в панели уведомлений. Мне нужно переопределить содержание городского протокола дирижабля. Есть ли какой -нибудь метод или способ сделать это. Я прошел документацию и ничего не смог найти.
Подробнее здесь: https://stackoverflow.com/questions/366 ... ge-content
UrbanairShip Настройка Push Notification Содержимое сообщений ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Push-уведомление React Native CLI (пакет npm response-native-push-notification)
Anonymous » » в форуме Android - 0 Ответы
- 29 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Apple Push Notification — настройте сообщение, которое будет отображаться при смене пропуска.
Anonymous » » в форуме IOS - 0 Ответы
- 21 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Laravel: не удается запустить Notification::assertSentTo при тестировании команды
Anonymous » » в форуме Php - 0 Ответы
- 25 Просмотры
-
Последнее сообщение Anonymous
-