Push URL doesn't open

CuriousPaul :

I have a pretty basic PushNotification code that should open an activity when no URL is present, and open an URL when there is one. But it doesn't open the URLs when the notification is received.

Code below

public class MyFirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
  private static final String TAG = "FirebaseMessagingServic";

  public MyFirebaseMessagingService() {}

  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getData().size() > 0) {
      Log.d(TAG, "Message data payload: " + remoteMessage.getData());
      try {
        JSONObject data = new JSONObject(remoteMessage.getData());
        String jsonMessage = data.getString("extra_information");
        Log.d(TAG, "onMessageReceived: \n" +
          "Extra Information: " + jsonMessage);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
    if (remoteMessage.getNotification() != null) {
      String title = remoteMessage.getNotification().getTitle();
      String message = remoteMessage.getNotification().getBody();
      String click_action = remoteMessage.getNotification().getClickAction();
      Uri uri = remoteMessage.getNotification().getLink();

      Log.d(TAG, "Message Notification Title: " + title);
      Log.d(TAG, "Message Notification Body: " + message);
      Log.d(TAG, "Message Notification click_action: " + click_action);
      Log.d(TAG, "Message Notification url: " + uri);

    }
  }

  @Override
  public void onDeletedMessages() {}

  private void sendNotification(String title, String messageBody, String click_action, Uri uri) {
    Intent intent;
    if (uri != null) {
      intent = new Intent(Intent.ACTION_VIEW);
      intent.setData(uri));
    } else {
      intent = new Intent(click_action);
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */ , intent,
      0);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
      .setSmallIcon(R.drawable.app_logo_final)
      .setContentTitle("PushNotification")
      .setContentText(messageBody)
      .setAutoCancel(true)
      .setSound(defaultSoundUri)
      .setContentIntent(pendingIntent);
    NotificationManager notificationManager =
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */ , notificationBuilder.build());
  }
}

And I am sending the notification like this:

{
  "to": "/topics/NEWS",
  "data": {
    "extra_information": "This is some extra information"
  },
  "notification": {
    "title": "Test title: http://www.google.com",
    "body": "Test body: http://www.google.com",
    "uri": "http://www.google.com",
    "click_action": "MAIN_PAGE"
  }
}

Inspired by other threads, I have:

  1. Tried to set Uri.parse("http://www.google.com"), to check if it would open www.google.com in any conditions, but it doesn't work.
  2. Added sendNotification(title, message, click_action, uri);. Didn't work
  3. Removed the if conditions and set only intent = new intent(Intent.ACTION_VIEW); intent.setData(uri));. Didn't work
  4. Replace the ACTIVITY from click_action with an URL. Didn't work
  5. Added an extra line with startActivity(intent)

In my Manifest, I have:

<activity android: name = ".MainScreen">
  <intent-filter>
    <action android: name = "android.intent.action.MAIN"/>
    <category android: name = "android.intent.category.LAUNCHER"/>
  </intent-filter> 
  <intent-filter>
    <action android: name = "MAIN_PAGE"/>
    <category android: name = "android.intent.category.DEFAULT"/>
  </intent-filter>

What it does right now is to open this MAIN_PAGE. Is there something else I need to add in the Manifest for opening a link?

EDIT: I have just discovered that I needed "link" instead of "uri" in Postman. Still, this didn't solve the problem. By looking at Logcat with the app running in the background, I have this when I click on the notification:

01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16186: Landroid / view / Window$Callback;.onPointerCaptureChanged(Z) V
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16188: Landroid / view / Window$Callback;.onProvideKeyboardShortcuts(Ljava / util / List; Landroid / view / Menu; I) V
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / view / SearchEvent;)
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16190: Landroid / view / Window$Callback;.onSearchRequested(Landroid / view / SearchEvent;) Z
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16194: Landroid / view / Window$Callback;.onWindowStartingActionMode(Landroid / view / ActionMode$Callback; I) Landroid / view / ActionMode;
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 811: Landroid / content / res / TypedArray;.getChangingConfigurations() I
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 833: Landroid / content / res / TypedArray;.getType(I) I
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0008
01 - 26 16: 51: 28.688 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16655: Landroid / widget / FrameLayout;.startActionModeForChild(Landroid / view / View; Landroid / view / ActionMode$Callback; I) Landroid / view / ActionMode;
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0002
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 560: Landroid / content / Context;.getColorStateList(I) Landroid / content / res / ColorStateList;
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0006
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / graphics / drawable / Icon;)
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.ImageButton.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageButton.setImageIcon
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16678: Landroid / widget / ImageButton;.setImageIcon(Landroid / graphics / drawable / Icon;) V
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0000
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 774: Landroid / content / res / Resources;.getDrawable(ILandroid / content / res / Resources$Theme;) Landroid / graphics / drawable / Drawable;
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 776: Landroid / content / res / Resources;.getDrawableForDensity(IILandroid / content / res / Resources$Theme;) Landroid / graphics / drawable / Drawable;
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications E / dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve instanceof 210(Landroid / graphics / drawable / RippleDrawable;) in Landroid / support / v7 / widget / AppCompatImageHelper;
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x20 at 0x000c
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16974: Landroid / widget / TextView;.getAutoSizeMaxTextSize() I
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16975: Landroid / widget / TextView;.getAutoSizeMinTextSize() I
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16976: Landroid / widget / TextView;.getAutoSizeStepGranularity() I
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16977: Landroid / widget / TextView;.getAutoSizeTextAvailableSizes()[I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16978: Landroid / widget / TextView;.getAutoSizeTextType() I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0008 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17021: Landroid / widget / TextView;.setAutoSizeTextTypeUniformWithConfiguration(IIII) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17022: Landroid / widget / TextView;.setAutoSizeTextTypeUniformWithPresetSizes([II) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17023: Landroid / widget / TextView;.setAutoSizeTextTypeWithDefaults(I) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16976: Landroid / widget / TextView;.getAutoSizeStepGranularity() I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0197 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve static method 15457: Landroid / text / StaticLayout$Builder;.obtain(Ljava / lang / CharSequence; IILandroid / text / TextPaint; I) Landroid / text / StaticLayout$Builder; 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x71 at 0x0014 01 - 26 16: 51: 28.828 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Connecting to remote service 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242636715 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications I / FA: Tag Manager is not found and thus will not be used 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): screen_view(_vs), Bundle[{
        firebase_event_origin(_o) = auto,
        firebase_screen_class(_sc) = Main_Screen,
        firebase_screen_id(_si) = 6213183756703048966
      }] 01 - 26 16: 51: 28.858 1395 - 1395 / com.tabian.firebasepushnotifications I / Adreno - EGL: < qeglDrvAPI_eglInitialize: 381 >: EGL 1.4 QUALCOMM build: (CL3869936) OpenGL ES Shader Compiler Version: 17.01 .12.SPL Build Date: 03 / 03 / 14 Mon Local Branch: default Remote Branch:
      Local Patches:
      Reconstruct Branch:
      01 - 26 16: 51: 28.918 1395 - 1395 / com.tabian.firebasepushnotifications D / OpenGLRenderer: Enabling debug mode 0 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / graphics / drawable / Icon;) 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.ImageView.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageView.setImageIcon 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16713: Landroid / widget / ImageView;.setImageIcon(Landroid / graphics / drawable / Icon;) V 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0000 01 - 26 16: 51: 28.948 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress 01 - 26 16: 51: 29.018 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Connected to remote service 01 - 26 16: 51: 29.018 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Processing queued up service tasks: 2 01 - 26 16: 51: 31.871 1395 - 1395 / com.tabian.firebasepushnotifications I / PersonaManager: getPersonaService() name persona_policy 01 - 26 16: 51: 31.881 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated 01 - 26 16: 51: 31.911 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Recording user engagement, ms: 2928 01 - 26 16: 51: 31.911 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity paused, time: 242639638 01 - 26 16: 51: 31.931 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): user_engagement(_e), Bundle[{
        firebase_event_origin(_o) = auto,
        engagement_time_msec(_et) = 2928,
        firebase_screen_class(_sc) = Main_Screen,
        firebase_screen_id(_si) = 6213183756703048966
      }] 01 - 26 16: 51: 31.941 1395 - 1395 / com.tabian.firebasepushnotifications E / ViewRootImpl: sendUserActionEvent() mView == null 01 - 26 16: 51: 32.091 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242639824 01 - 26 16: 51: 37.097 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Inactivity, disconnecting from the service

When the app is opened, when I send the notification, it shows this:

01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message data payload: {
  extra_information = This is some extra information
}
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: onMessageReceived:
  Extra Information: This is some extra information
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification Title: Test title: http: //www.google.com
  01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification Body: Test body: http: //www.google.com
  01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification click_action: MAIN_PAGE
01 - 26 16: 53: 29.106 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification url: http: //www.google.com
  01 - 26 16: 53: 35.293 1395 - 1395 / com.tabian.firebasepushnotifications I / PersonaManager: getPersonaService() name persona_policy
01 - 26 16: 53: 35.313 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated
01 - 26 16: 53: 35.353 1395 - 1395 / com.tabian.firebasepushnotifications E / ViewRootImpl: sendUserActionEvent() mView == null
01 - 26 16: 53: 35.353 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Recording user engagement, ms: 16086
01 - 26 16: 53: 35.353 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connecting to remote service
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Activity paused, time: 242763126
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242763247
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): user_engagement(_e), Bundle[{
  firebase_event_origin(_o) = auto,
  engagement_time_msec(_et) = 16086,
  firebase_screen_class(_sc) = Main_Screen,
  firebase_screen_id(_si) = 6213183756703048969
}]
01 - 26 16: 53: 35.423 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress
01 - 26 16: 53: 35.493 1395 - 1845 / com.tabian.firebasepushnotifications D / FA: Connected to remote service
01 - 26 16: 53: 35.493 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Processing queued up service tasks: 3

Eduardo Herzer :

You are sending notification payload in the push json. This will make onMessageReceived not being called.

From firebase docs (https://firebase.google.com/docs/cloud-messaging/android/receive?hl=en):

onMessageReceived is provided for most message types, with the following exceptions:

  • Notification messages delivered when your app is in the background. In this case, the notification is delivered to the device’s system tray. A user tap on a notification opens the app launcher by default.
  • Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.

So if you want to handle the notification yourself, you should send only data payload.

Also, at your code, you are not calling sendNotification(String title, String messageBody, String click_action, Uri uri) anywhere.

sendNotification implementation is correct and working fine. You just forgot to call it inside onMessageReceived!!

EDIT:

To get data payload, you should use remoteMessage.getData() instead of remoteMessage.getNotification()

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=464231&siteId=1