I'm trying to send a notification with URL from MobilePush in Marketing Cloud with OpenDirect feature.

When the user clicked on an alert notification. I want a web page or landing page to show on mobile phone

I already enable the OpenDirect Feature in the Apps in MobilePush tabs

And this is what my code looks like

MarketingCloudSdk.init(this, MarketingCloudConfig.builder()
                                new NotificationManager.NotificationLaunchIntentProvider() {
                                    @Nullable @Override
                                    public PendingIntent getNotificationPendingIntent(@NonNull Context context,
                                                                                      @NonNull NotificationMessage notificationMessage) {
                                        int requestCode = new Random().nextInt();
                                        String url = notificationMessage.url();
                                        PendingIntent pendingIntent;
                                        if (TextUtils.isEmpty(url)) {
                                            pendingIntent = PendingIntent.getActivity(
                                                    new Intent(context, MainActivity.class),
                                        } else {
                                            pendingIntent = PendingIntent.getActivity(
                                                    new Intent(Intent.ACTION_VIEW, Uri.parse(url)),
                                        return NotificationManager.redirectIntentForAnalytics(context, pendingIntent, notificationMessage, true);
                                }, new NotificationManager.NotificationChannelIdProvider() {
                                    @NonNull @Override public String getNotificationChannelId(@NonNull Context context,
                                                                                              @NonNull NotificationMessage notificationMessage) {
                                        if (TextUtils.isEmpty(notificationMessage.url())) {
                                            return NotificationManager.createDefaultNotificationChannel(context);
                                        } else {
                                            return "UrlNotification";
                .build((Context) this), new MarketingCloudSdk.InitializationListener() {
            @Override public void complete(@NonNull InitializationStatus status) {
                // TODO handle initialization status

I try to learn how to use this feature from this link : http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/notifications/customize-notifications.html

Before that I can get an alert notification without OpenDirect Feature, Now I cannot get any notification from the mobile push after I'm trying to use OpenDirect

  • please post your code instead of a screenshot – glls Mar 30 '19 at 15:05
  • Okay I already edit a post – Napathorn Kaeokomonmarn Mar 31 '19 at 0:20
  • 1
    @NapathornKaeokomonmarn if the values in your code sample for appId, accessToken, senderId, mid and marketing cloud url are your application's actual values you should remove them. – Seth Apr 1 '19 at 10:15
  • @Seth I have fixed all of the things that you told me in the previous answer. And good thing happened , the code is work thank for your help – Napathorn Kaeokomonmarn Apr 9 '19 at 4:45

Since your code is a direct copy from the coding example in our documentation then I would assume that you have not created a notification channel with the channel id of "UrlNotification."

If your intention is to have OpenDirect notifications be posted to a different channel then you should follow the suggested implementation for creating a notification channel in our documentation. http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/notifications/custom-channels.html

If you want all notifications to be posted to the SDK's default channel then you can replace your implementation of NotificationManager.NotificationChannelIdProvider with null.

  • Thank you for your answer. I already solve my case. I can send a Mobile Notification to the device with the deep link. – Napathorn Kaeokomonmarn Apr 9 '19 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.