Retrieving custom key/value using deeplink

How can I get the custom values through deeplink in android. Other than passing parameters in uri, is there a way to get the custom values from Intent?

Hi,

Sure, there is.

You need to listen to the INTENT_NOTIFICATION_OPENED local broadcast and extract the original push Intent from the INTENT_NOTIFICATION_OPENED_EXTRA_RECEIVED_PUSH_NOTIFICATION extra:

// Put the following call before you initialize the SDK, in your Application class for example
LocalBroadcastManager.getInstance(this).registerReceiver(new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Read whether the user clicked the notification (true) or if it was automatically opened (false)
        boolean fromUserInteraction = intent.getBooleanExtra(WonderPush.INTENT_NOTIFICATION_OPENED_EXTRA_FROM_USER_INTERACTION, true);
        // Get the original push notification received intent
        Intent pushNotif = intent.getParcelableExtra(WonderPush.INTENT_NOTIFICATION_OPENED_EXTRA_RECEIVED_PUSH_NOTIFICATION);
        if (pushNotif != null) {
            // Perform desired action, like reading custom key-value payload
        }
    }
}, new IntentFilter(WonderPush.INTENT_NOTIFICATION_OPENED));

Best,

Thanks Olivier!

This I have used already. I have a confusion on choosing Action in COMPOSE section. Do I want to select “open deep link” or “Let application code decide” ? I want this to work over deep link, If we go via deep link, our broadcast receiver will not trigger. Kindly help me to resolve this.

Thanks in advance.

Hi,

What you are using is the code described in Features / Advanced click handling / Handling click broadcasts, which handles exclusively the clicks on notifications where you’ve chosen “Let application code decide”.
The code I’ve given you here let’s you handle regular notification clicks.

Note that as the Intent is delivered to the target Activity (either in onCreate or onNewIntent), you have access to that same intent there. That enables you to handle it on a specific activity.
The code in my previous post is simpler to use in a centralized place, in your Application class.

Best,

Thanks Olivier,

I got it. Thinks working fine on handling on a specific activity and broadcast receiver as well.

Regards,