summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-firebase/src/android/OnNotificationOpenReceiver.java
blob: a7f63757d58f37abb1704b0e4be6a56909caf876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.apache.cordova.firebase;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;

public class OnNotificationOpenReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        PackageManager pm = context.getPackageManager();
        Intent launchIntent = pm.getLaunchIntentForPackage(context.getPackageName());

        launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle data = intent.getExtras();
        data.putBoolean("tap", true);
        FirebasePlugin.sendNotification(data);
        launchIntent.putExtras(data);
        context.startActivity(launchIntent);
    }
}