1

MobilePush (Android) SDK (v.7.1.0)

We are using Full Control Customization Notification handling by following the document noted here: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/notifications/customize-notifications.html

But, tapping on the notification does not launch the App if the App is killed/closed forcefully after getting the notification.

However, It was working as expected until we decide to use the "analytics helper method" (NotificationManager.redirectForAnalytics()) as suggested in the document. But after adding the "analytics helper method" it is not working as expected in the scenario mentioned above.

I really appreciate by getting some help with this issue :)

Thanks in advance

[Edit - 28 May 2020]

For a detailed understanding, I am posting how the custom notification implementation has done. Please note that some of the codes blocked had been taken out for the context

class SalesForceManager {

    /**
     * Initialize Sales force SDK
     */
    fun init(context: Context, sharedPreferences: PreferencesHelper): SalesForceManager {
        this.pref = sharedPreferences
        this.context = context

        MarketingCloudSdk.init(context, MarketingCloudConfig.builder().apply {
            ...
            setNotificationCustomizationOptions(
                    customizeNotification()
            )
            // Other configuration options
        }.build(context)) { initStatus ->
            when (initStatus.status) {
            ...
            }
        }

        return this
    }

    private fun customizeNotification(): NotificationCustomizationOptions {
        return NotificationCustomizationOptions.create { context, notificationMessage ->
            Timber.d("notificationMessage  = $notificationMessage")
            saveNotificationId(notificationMessage)
            val builder = NotificationManager.getDefaultNotificationBuilder(
                    context,
                    notificationMessage,
                    createNotificationChannel(context),
                    R.drawable.ic_notification_small
            )
            builder.color = ContextCompat.getColor(context, R.color.red)
            builder.setColorized(true)
            builder.setAutoCancel(true)
            builder.setContentIntent(getPendingIntent(context, notificationMessage)
            )
        }
    }

    private fun getPendingIntent(context: Context, msg: NotificationMessage): PendingIntent {
        // SplashActivity.getPendingIntent(context, msg)        // --> WORKS
        return NotificationManager.redirectIntentForAnalytics(  // --> NOT WORKS as expected
                context,
                SplashActivity.getPendingIntent(context, msg),
                msg,
                true
        )
    }
}

class SplashActivity : BaseActivity() {

    companion object {
        fun getPendingIntent(context: Context, msg: NotificationMessage): PendingIntent {
            val intent = Intent(context, SplashActivity::class.java).apply {
                flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
            }
            intent.putExtra(IntentKeys.NOTIFICATION_DATA, msg)
            return PendingIntent.getActivity(
                    context,
                    Random.nextInt(),
                    intent,
                    PendingIntent.FLAG_ONE_SHOT
            )
        }
    }
}

I also adding logs showing the notification tapped

2020-05-28 14:35:25.725 18699-18699/? I/zygote: Not late-enabling -Xcheck:jni (already on)
2020-05-28 14:35:25.752 18699-18699/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
2020-05-28 14:35:25.811 18699-18699/au.com.medibank.phs W/System.err: java.io.FileNotFoundException: /jacoco.exec (Read-only file system)
2020-05-28 14:35:25.812 18699-18699/au.com.medibank.phs W/System.err:     at java.io.FileOutputStream.open0(Native Method)
2020-05-28 14:35:25.812 18699-18699/au.com.medibank.phs W/System.err:     at java.io.FileOutputStream.open(FileOutputStream.java:287)
2020-05-28 14:35:25.812 18699-18699/au.com.medibank.phs W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
2020-05-28 14:35:25.812 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
2020-05-28 14:35:25.812 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at au.com.medibank.phs.MedibankApplication.$jacocoInit(Unknown Source:13)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at au.com.medibank.phs.MedibankApplication.<init>(Unknown Source:0)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at java.lang.Class.newInstance(Native Method)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at android.app.Instrumentation.newApplication(Instrumentation.java:1101)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at android.app.Instrumentation.newApplication(Instrumentation.java:1086)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at android.app.LoadedApk.makeApplication(LoadedApk.java:965)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5765)
2020-05-28 14:35:25.813 18699-18699/au.com.medibank.phs W/System.err:     at android.app.ActivityThread.-wrap1(Unknown Source:0)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at android.os.Looper.loop(Looper.java:164)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6541)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2020-05-28 14:35:25.814 18699-18699/au.com.medibank.phs W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2020-05-28 14:35:25.851 18699-18699/au.com.medibank.phs I/FirebaseInitProvider: FirebaseApp initialization successful
2020-05-28 14:35:25.858 18699-18699/au.com.medibank.phs W/com.facebook.internal.Validate: FacebookActivity is not declared in the AndroidManifest.xml. If you are using the facebook-common module or dependent modules please add com.facebook.FacebookActivity to your AndroidManifest.xml file. See https://developers.facebook.com/docs/android/getting-started for more info.
2020-05-28 14:35:25.887 18699-18726/au.com.medibank.phs D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-05-28 14:35:26.001 18699-18740/au.com.medibank.phs I/stetho: Listening on @stetho_au.com.medibank.phs_devtools_remote
2020-05-28 14:35:26.011 18699-18699/au.com.medibank.phs I/WebViewFactory: Loading com.android.chrome version 81.0.4044.138 (code 404413821)
2020-05-28 14:35:26.064 18699-18699/au.com.medibank.phs I/cr_LibraryLoader: Loaded native library version number "81.0.4044.138"
2020-05-28 14:35:26.090 18699-18699/au.com.medibank.phs W/ResourceType: For resource 0x7f130540, entry index(1344) is beyond type entryCount(686)
2020-05-28 14:35:26.090 18699-18699/au.com.medibank.phs W/ResourceType: Failure getting entry for 0x7f130540 (t=18 e=1344) (error -75)

  • Enable logging and provide the output from the point where you're clicking the notification. You will be looking for D/BehaviorManager: Behavior found: BEHAVIOR_SDK_NOTIFICATION_OPENED. Also, open a support case through your account representative. – Bill Mote May 26 at 14:31
  • Please ensure that you have initialized the SDK in your application's Application#onCreate() as prescribed in the docs salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/… – Bill Mote May 26 at 14:35
  • It would also be incredibly helpful if you shared your usage of the helper method to include the PendingIntent you're trying to use. I independently verified that this method works by building a "hello world" application, integrating our SDK with a builder passed in to the NotificationOptions and it works perfectly. – Bill Mote May 27 at 14:41
  • @BillMote thanks for your feedback. I have updated the question as it gives a much clear idea about our issue. As you can see the logs we can't even get the logs related BehaviorManager – zkglr May 28 at 5:02
  • And where are you initializing the SDK? If your application has been force closed then I would expect to see the SDK being initialized as a result of your Application#onCreate() being executed. – Bill Mote May 28 at 15:44
0

You must initialize the SDK in your application's Application#onCreate.

| improve this answer | |

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.