Android 城市航空定制推送通知信息内容

Android 城市航空定制推送通知信息内容,android,json,notifications,push-notification,urbanairship.com,Android,Json,Notifications,Push Notification,Urbanairship.com,我正在使用城市飞艇向我的android应用程序发送推送通知。我正在从后端服务器发送一个json内容作为推送内容 推送工作正常&我可以获取推送内容。推送消息也显示在设备通知栏中 但问题是推送通知显示json内容。我需要定制它&显示一条人类可读的信息 这是我的IntentReceiver类中的onPushReceived方法 @Override protected void onPushReceived(Context context, PushMessage message, int notifi

我正在使用城市飞艇向我的android应用程序发送推送通知。我正在从后端服务器发送一个json内容作为推送内容

推送工作正常&我可以获取推送内容。推送消息也显示在设备通知栏中

但问题是推送通知显示json内容。我需要定制它&显示一条人类可读的信息

这是我的IntentReceiver类中的onPushReceived方法

@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());

}
我可以解码推送内容

我试图通过NotificationManager添加通知,但它在通知栏中显示了两个通知。我需要覆盖城市飞艇推进的内容。有什么方法或方法可以做到这一点吗。我查阅了文档,什么也没找到

希望有人能帮助我


感谢您的帮助。

城市飞艇支持定制通知,但您需要让城市飞艇发布通知。您将希望在接收者中提供一个而不是构建一个发布通知。但是,您可能可以通过不发送JSON内容作为消息警报来避免这种情况,而是将额外数据作为推送有效负载中的额外数据发送。

城市飞艇支持自定义通知,但您需要让城市飞艇发布通知。您将希望在接收者中提供一个而不是构建一个发布通知。不过,您可能可以避免这种情况,方法是不将JSON内容作为消息警报发送,而是将额外数据作为推送负载中的额外数据发送。

非常感谢。我想你回答了我的问题:)非常感谢。我想你回答了我的问题:)