0

I have an Android mobile app in which I have implemented Marketing Cloud Push SDK (https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/, version 8.0.7) and Firebase Cloud Messaging (version 23.0.1). When I try to send notifications from FCM to my app (killed), I receive all correctly on my device. When I try to send notifications with Marketing Cloud (outbound or via Journey Builder), I receive "silently" the notification in my Firebase Messaging Service class.

This is my sdk initialization class:

MarketingCloudConfig marketingCloudConfig = MarketingCloudConfig.builder()
                .setApplicationId("*********")
                .setAccessToken("*************")
                .setSenderId("***********")
                .setMarketingCloudServerUrl("*******************")
                .setMid("***************")
                .setDelayRegistrationUntilContactKeyIsSet(true)
                .setInboxEnabled(false)
                .setGeofencingEnabled(false)
                .setProximityEnabled(false)
                .setPiAnalyticsEnabled(false)
                .setAnalyticsEnabled(false)
                .setNotificationCustomizationOptions(
                    //NotificationCustomizationOptions.create(R.drawable.ic_notification_icon)
                        NotificationCustomizationOptions.create(new NotificationManager.NotificationBuilder() {
                            @NonNull
                            @Override
                            public NotificationCompat.Builder setupNotificationBuilder(@NonNull Context context,
                                                                                       @NonNull NotificationMessage notificationMessage) {
                                NotificationCompat.Builder builder =
                                        NotificationManager.getDefaultNotificationBuilder(
                                                context,
                                                notificationMessage,
                                                NotificationManager.createDefaultNotificationChannel(context),
                                                R.drawable.ic_launcher
                                        );

                                builder.setContentIntent(
                                        NotificationManager.redirectIntentForAnalytics(
                                                context,
                                                PendingIntent.getActivity(
                                                        context,
                                                        new Random().nextInt(),
                                                        new Intent(context, ItemListFragment.class),
                                                        PendingIntent.FLAG_UPDATE_CURRENT
                                                ),
                                                notificationMessage,
                                                true
                                        )
                                );
                                return builder;
                            }
                        })
                ).build(this.getContext().getApplicationContext());

            MarketingCloudSdk.init(this.getContext(), marketingCloudConfig, initializationStatus -> {
                Log.d(TAG, "MarketingCloudSdk initialized: " + initializationStatus);
                Log.d(TAG, "MarketingCloudSdk initialized: isUsable() is " + initializationStatus.isUsable());

                if(initializationStatus.status().toString().equals("COMPLETED_WITH_DEGRADED_FUNCTIONALITY")){
                    if (initializationStatus.locationsError()) {

                        Log.d(TAG, "MarketingCloudSdk initialized: locationsError is true");

                        //Handle Google Play Services issues.
                        if (GoogleApiAvailability.getInstance().isUserResolvableError(initializationStatus.playServicesStatus())) {
                            // User will likely need to update GooglePlayServices through the Play Store.
                            // Call GoogleApiAvailability.getInstance().showErrorDialogFragment(...) from Activity.
                            Log.d(TAG, "MarketingCloudSdk initialized: update GooglePlayServices through the Play Store");
                        }
                    } else if (initializationStatus.messagingPermissionError()) {
                        // User disabled location permission.
                        // Re-request permission and if granted enable desired messaging type
                        Log.d(TAG, "MarketingCloudSdk initialized: User disabled location permission");
                    }
                }else if(initializationStatus.status().toString().equals("SUCCESS")){
                    Log.d(TAG, "MarketingCloudSdk initialized: success");
                }else if(initializationStatus.status().toString().equals("FAILED")){
                    Log.d(TAG, "MarketingCloudSdk initialized: failed");
                }
            });

Has anyone ever encountered this type of problem? These are all the information about my Android Studio project:

  • Android Studio version: Dolphin 2021.3.1 Patch 1
  • Android Grandle Plugin Version: 7.3.1
  • Grandle Version: 7.4
  • Target SDK Version: 32
  • Min SDK Version: 21
  • Firebase Messaging: 23.0.1
  • Marketing Cloud Push SDK Version: 8.0.7

1 Answer 1

0

You're targeting SDK v32, but you're not setting the mutability flag for your intent.

PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE

The LogCat probably calls it out explicitly if you look.

ref. https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

Additionally, you're providing a senderId during SDK configuration, and you reference your own Firebase message handler. See https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/trouble-shooting/multiple-push-sdks.html

UPDATE: Either follow the Multiple Push Provider implementation instructions completely or remove your own "Firebase Messaging Service" class. The notifications are being intercepted by your class and you have not passed them on to our SDK.

Your other route is to open a support request.

5
  • Hi Bill I have tried to change from PendingIntent.FLAG_UPDATE_CURRENT to PendingIntent.FLAG_IMMUTABLE but notification is not arrived from MC Mobile Push UI. Have you got some examples to use? Commented Nov 29, 2022 at 19:20
  • Does it work when you only use the icon option as shown in your code? We send billions of messages successfully every day ;) It will never work unless you add the immutability flag. Additionally, it appears that you have failed to follow the Multiple Push Provider implementation instructions from the docs.
    – Bill Mote
    Commented Nov 29, 2022 at 19:56
  • Hi Bill I am not implementing multiple push sdk, however I try to remove senderId from Marketing Cloud initialization but result was the same. Commented Nov 30, 2022 at 8:46
  • When I try to send notifications with Marketing Cloud (outbound or via Journey Builder), I receive "silently" the notification in my Firebase Messaging Service class. ... 100% a multiple push provider setup.
    – Bill Mote
    Commented Nov 30, 2022 at 13:38
  • Thank you Bill, removing Firebase Messaging Service class has resolved my problem! Commented Dec 13, 2022 at 9:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .