私はFirebas mesagingサービスクラスを使用しています。アプリケーションがフォアグラウンドで実行されているときに正しく動作しますが、最近このアプリケーションをクリアすると、プッシュ通知データにアクセスできないため、テキストビューで設定します。 アプリがバックグラウンドで実行されているときに、データをデータベースに保存したい。 値を直接格納するためにデータベースを使用しましたが、その値は機能しませんでした。通知をバックグラウンドで使用する
public void onMessageReceived(RemoteMessage message) {
database=new SQLiteHelper(getApplicationContext());
database.open();
String image = message.getNotification().getIcon();
String title = message.getNotification().getTitle();
String text = message.getNotification().getBody();
String sound = message.getNotification().getSound();
int id = 0;
database.addQuotes(text,"Xyz");
Bundle extras = getIntent().getExtras();
if (extras != null) {
final String message = extras.getString("message");
quote_text.setText(message);
Toast.makeText(this, "A", Toast.LENGTH_SHORT).show();
}
のonCreate方法で
} MainActivity.javaで
しかし、メッセージは、NULLデータを示しています。バックグラウンドで私はアプリが実行されている場合、データベースにデータを格納したい
FirebaseMessagingService
がプッシュと呼ばれるonMessageReceived
というメソッドを持っている拡張サービスコール:これに基づいて
はあなたdatabase.addQuotes()メソッド – MadScientist