Send deep link from Google cloud messaging

1

I am using the Google cloud messaging service to send push notification to my android app.

Now I would be interested in sending a deep link in the push notifications, so that when the user presses on the push, it takes him directly to a section within the app

Is it possible to do this, or will I definitely have to use payment services where they offer the deep link?

    
asked by Marcos 10.03.2016 в 18:14
source

1 answer

0

Of course it can be achieved, obviously you would have to add another data in the notification, for example "deepUrl" that could contain the name of the section, a url:

http://www.marcos.com/nacional

or a custom scheme:

seccion://nacional

Based on that, when you receive your notification in onHandleIntent() , open your section.

@Override
protected void onHandleIntent(Intent intent){
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);        
    String messageType = gcm.getMessageType(intent);
    Bundle extras = intent.getExtras();
    if (!extras.isEmpty()){  
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)){

                                             String titulo = extras.getString("titulo");
                                             String descripcion = extras.getString("descripcion");
                                             String imagen = extras.getString("img");
                                             String deepUrl = extras.getString("deepUrl");

                                             abreSeccion(deepUrl);



        }else{
            Log.w(TAG, "Tipo de notificación desconocido.");
        }
    }        
    GCMBroadcastReceiver.completeWakefulIntent(intent);
}   
    
answered by 10.03.2016 / 19:20
source