0

私は都市飛行船を使用してアンドロイドアプリケーションにプッシュ通知を送信しています。バックエンドサーバーからjsonコンテンツをプッシュコンテンツとして送信していますUrbanairshipはプッシュ通知メッセージの内容をカスタマイズします

プッシュが正しく動作しています&プッシュコンテンツを取得できます。プッシュメッセージがデバイスの通知バーにも表示されます。

しかし、問題はプッシュ通知が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から通知を追加しようとしましたが、通知バーに2つの通知が表示されました。私は都市飛行船のプッシュの内容を無効にする必要があります。それを行う方法や方法はありますか?私は文書&に行きました。何も見つかりませんでした。

は高度で

おかげ..いずれかが私を助けることができます願っています。

答えて

2

アーバン・エアーシップはカスタム通知をサポートしていますが、アーバン・エアシップが通知を送信する必要があります。受信者に通知を投稿するのではなく、custom notification factoryを提供することをお勧めします。ただし、JSONコンテンツをメッセージアラートとして送信しないで、余分なデータをプッシュペイロードに余分に送信することで、これを回避できます。

+0

ありがとうございます。私はあなたが私の質問に答えたと思う:) –

関連する問題