ayeshchanaka
ayeshchanaka

Reputation: 154

how to open a specific UserInterface, onClicking on firebase push notification in android studio?

*androidMainfest

<service
    android:name=".backgroundService.FirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>

Upvotes: 0

Views: 84

Answers (2)

ayeshchanaka
ayeshchanaka

Reputation: 154

On launcher activer

if (getIntent().getExtras() != null) {
    for (String key : getIntent().getExtras().keySet()) {
        String value = getIntent().getExtras().getString(key);
        Log.d(TAG, "Key: " + key + " Value: " + value);
    }
}

Upvotes: 0

Satish Navada
Satish Navada

Reputation: 381

As per the documentation, when messages with both notification and data payload are received and application is in background mode, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of launcher Activity. Option 1: You can try to to handle the data in launch activity and from there launch UserDetailsActivity and finish launcher activity quickly without showing UI. https://firebase.google.com/docs/cloud-messaging/android/receive

Option 2: Dont send notification part from FCM and send only payload part. In onmessagereceived() method ,construct the notification with pending intent for UserDetails activity or service.

Upvotes: 0

Related Questions