How to identify GCM notifications with Link and Text?

2

I currently receive notifications perfectly in my app, but I want to know how to identify when a notification brings a link (link) or just want to initiate an Activity.class

    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra("link", link);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

As you can see I have the two parameters to start the two types of notification but the app only detects the Intent with the Class, although it has a link in the notification.

In Summary: How can I put two Intent to detect what type of notification it is.

Update: Solution 1 gives the following Error

    
asked by Bryan B Weiss 17.08.2016 в 22:50
source

1 answer

0

The validation would be done in this way:

if(link != null && !link.isEmpty()){
   //Abre url.
   Intent i  = new Intent(Intent.ACTION_VIEW, Uri.parse("VARIABLE CON LA URL/")); 
   startActivity(i);
}else{
   //Abre activity mediante PendingIntent
   Intent intent = new Intent(this, MainActivity.class);
   PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
   ...
}
    
answered by 17.08.2016 / 22:58
source