プッシュ通知受信履歴管理¶
RichFlyer SDKは、プッシュ通知の受信履歴を最大10件保持しています。 その履歴の取得及び、履歴から指定したプッシュ通知の内容をアプリ上で表示させることができます.
プッシュ通知受信履歴の取得¶
保持している10件のプッシュ通知受信履歴を取得します。
// RichFlyerクラス
static ArrayList<RFContent> getHistory(Context context)
| パラメータ | 内容 |
|---|---|
| context | アプリケーションのContext |
RFContentクラス¶
受信履歴から取得できるプッシュ通知の情報はRFContentオブジェクトに保持されます。
| 項目 | 内容 | 取得メソッド名 | 型 |
|---|---|---|---|
| ID | 通知ID | getNotificationId() | String |
| タイトル | 通知タイトル | getTitle() | String |
| メッセージ | 通知メッセージ本文 | getMessage() | String |
| 画像パス( 注1 ) | 添付した画像の保存先 | getImagePath() | String |
| GIFパス( 注2 ) | 添付したGIFの保存先 | getGifPath() | String |
| 動画パス( 注2 ) | 添付した動画の保存先 | getMoviePath() | String |
| 通知タイプ( 注3 ) | 通知に添付したコンテンツのタイプ | getContentType() | int |
| 受信日時 | 端末が通知を受信した日時(UNIXタイム)端末に依存します | getRecievedDate() | Long |
| 配信日時 | RichFlyerから通知が配信された日時(UNIXタイム) | getNotificationDate() | Long |
| アクションボタン | 設定されたアクションボタンの内容(ActionButtonクラス)を配列で返します | getActionButtonArray() | ActionButton |
| 拡張プロパティ | 拡張プロパティ | getExtendedProperty() | String |
(注1):プッシュ通知の受信時に保存したパスを返します。
(注2):GIFもしくは動画を添付した場合は、通知ダイアログを1度も表示していない場合は null が返されます。
(注3):通知タイプの種類は以下の通りです。
| 通知タイプ | 値 |
|---|---|
| テキストのみ | 0 |
| 画像のみ | 1 |
| GIFあり | 2 |
| 動画あり | 3 |
ActionButtonクラス¶
複数設定できるアクションボタンの内容を格納するクラスです。
| 項目 | 内容 | 取得メソッド名 | 型 |
|---|---|---|---|
| インデックス | ボタンのインデックス(0~2) | getIndex() | int |
| アクションタイプ | アクションのタイプ | getActionType() | String |
| アクション | アクションの内容(URLなど) | getAction() | String |
実装例¶
Java
ArrayList<RFContent> notifications = RichFlyer.getHistory(getApplicationContext());
for (RFContent content : notifications) {
// プッシュ通知のタイトル
Log.d("richflyer", content.getTitle());
// プッシュ通知の本文
Log.d("richflyer", content.getMessage());
// 保存されている画像のパス
Log.d("richflyer", content.getImagePath());
// 通知ID
Log.d("richflyer", content.getNotificationId());
}
最新のプッシュ通知¶
保持している受信履歴から直近に受信したプッシュ通知の情報を取得します。
// RichFlyerクラス
static RFContent getLatestNotification(Context context);
| パラメータ | 内容 |
|---|---|
| context | アプリケーションのContext |
実装例¶
Java
RFContent content = RichFlyer.getLatestNotification(getApplicationContext());
// プッシュ通知のタイトル
Log.d("richflyer", content.getTitle());
// プッシュ通知の本文
Log.d("richflyer", content.getMessage());
// 保存されている画像のパス
Log.d("richflyer", content.getImagePath());
// 通知ID
Log.d("richflyer", content.getNotificationId());
受信した通知の表示¶
受信履歴から取得した通知情報をダイアログで表示することができます。

//RichFlyerクラス
static void showHistoryNotification(Context context, String payloadId)
| パラメータ | 内容 |
|---|---|
| context | アプリケーションのContext |
| payloadId | 通知ID(RFContent.getNotificationId) |
実装例¶
Java
RFContent content = RichFlyer.getLatestNotification(getApplicationContext());
if (content != null) {
RichFlyer.showHistoryNotification(getApplicationContext(), content.getNotificationId());
}