How to store received push notification from Firebase remote messages into sqlite database when app is in background?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to store received push notification from Firebase remote messages into sqlite database when app is in background?



i have tried this code.but i can't handle remote messages even i can't print in logcat.


@Override
public void onNewToken(String s) {
super.onNewToken(s);
Log.d("token",s);
}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

if (remoteMessage.getData().size() > 0){

Log.d("remoteMsg",remoteMessage.getData().toString());

String title,message,Id;

Map data = remoteMessage.getData();

title = data.get("title").toString();
message = data.get("body").toString();
Id = data.get("NotifyId_Enc").toString();


try {
JSONObject json = new JSONObject(remoteMessage.getData().toString());
handleDataMessage(json);

Log.d("fol", String.valueOf(json));
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}

Intent intent = new Intent(this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
Uri soundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(message);
notificationBuilder.setContentText(Id);
notificationBuilder.setSound(soundUri);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);


}else {
Log.d("remoteMsg","not working");
}



}



i am sending notification from .net web server and receiving fcm remote messages but i can't handle it.



my question is about how to handle remote messages .. thats all









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

0ay,K,hU4txq,UOjr Sx000FHWBnb,ve5hYjU
okjKVr2al0nC7kNAmiGh5,ZTzG

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham