Deep Link with Push Notification - FCM - Android

Multi tool use
Multi tool use


Deep Link with Push Notification - FCM - Android



What I want: I want to send push notification to users. When user tap on that notification, user should navigate to specific activity.



What I did: I created one deep link in Firebase console. I implemented FirebaseInstanceIdService & FirebaseMessagingService as well. I'm able to catch Firebase message which I sent from Firebase console.



What is the issue: I'm not able to catch the dynamic link what I have created in Firebase console.



My code is like below.



MyFirebaseInstanceIDService.java


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

private final String TAG = "MyFirebaseInstanceID";

@Override
public void onTokenRefresh() {

String refreshedToken = FirebaseInstanceId.getInstance().getToken();

Log.e(TAG, "Refreshed token: " + refreshedToken);
}
}



MyFirebaseMessagingService.java


public class MyFirebaseMessagingService extends FirebaseMessagingService {

private final String TAG = "MyFbaseMessagingService";

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

String message = remoteMessage.getNotification().getBody();

Log.e(TAG, "nmessage: " + message);

sendNotification(message);
}

private void sendNotification(String message) {

Intent intent = new Intent(this, TestDeepLinkActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("FCM Test")
.setContentText(message)
.setSound(defaultSoundUri)
.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setContentIntent(pendingIntent);

NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

manager.notify(0, builder.build());
}
}



Firebase Console Image



Firebase Console Image









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.

IfS52B g0v9HeGYPEBXedBW0RFL7KzT2
M8fE7ABHSM 0N som6I8,F,nliXkDo,VIA

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications