CleverTap / clevertap-android-sdk

CleverTap Android SDK
MIT License
80 stars 74 forks source link

SplashActivity does not excluded from CLEVERTAP_INAPP_EXCLUDE #218

Closed afarhan39 closed 2 years ago

afarhan39 commented 2 years ago

Describe the bug In App Notifications does not obey CLEVERTAP_INAPP_EXCLUDE tag despite added correct Activity to exclude.

To Reproduce Steps to reproduce the behavior:

  1. Add SplashActivity inside CLEVERTAP_INAPP_EXCLUDE
  2. Create campaign for in app notification, and send test campaign
  3. Received push notification due to send test campaign, refer here
  4. Tap on push notification. App will open and showing In App Notification on Splash, and dismissed it when going to HomeActivity, despite already done Step 1.

Expected behavior I'm expecting In App Notification to be shown in HomeActivity, instead of SplashActivity.

Screenshots/Logs Please see attached video. InAppVid.webm

Environment (please complete the following information):

Additional context

root-ansh-ct commented 2 years ago

Hi @afarhan39 . can you please do the following:

  1. provide logs till the login screen, filtered by "clevertap" tag
  2. verify if you added the whole name of the activity(i.e package+activity name) or just the class name, in the manifest?
  3. share the conditions used for creating the target audience Mainly the values here, when you create the campaign: image
darshanclevertap commented 2 years ago

@afarhan39 If you are still facing the issue, please feel free to reopen this with the info asked. Thanks!

walaankit commented 1 year ago

verify if you added the whole name of the activity(i.e package+activity name) or just the class name, in the manifest?

@darshanclevertap What should be used, with package name or without?

william-ct commented 1 year ago

@walaankit To exclude in-app from any specified activity, you need to specify only the activity name. More info regarding the same can be found here

AkimovAN commented 1 year ago

@william-ct I spent a lot of time to debugging and found the following - you need to specify the full name of the activity изображение

this method in library

william-ct commented 1 year ago

@AkimovAN

you need to specify the full name of the activity

How did you conclude the above result from the sample you've shared? In the screenshot, you're blacklisted activity is StartActivity and your current activity ui.activities.SplashScreenActivity, in this specific case canShowInAppOnActivity() will return true.

Also if you can see line 343 we get the local class name from CoreMetaData.getCurrentActivityName() and does a contains check with blackListedActivity string value. So if it(blackListedActivity) has the entire ActivityName/getLocalClassName(package_activityName) or only the activityName/getSimpleClassName(activityName), canShowInAppOnActivity() method will return false when currentActivityName contains blackListedActivity string value.

@walaankit Do let us know here if it has solved your issue.Thanks

AkimovAN commented 1 year ago

@william-ct Ignore the activity names from the screenshot - I only show that if you specify the only activity name in the manifest, then this name will be added to the inappActivityExclude list, while CoreMetaData.getCurrentActivityName() returns the full name of the activity, including package name. This is what I was trying to show in the screenshot

william-ct commented 1 year ago

@AkimovAN So if you specify only activityName or activityName(including the package) in the manifest, then in-app notification will always be excluded/not shown in the specified activity.

AkimovAN commented 1 year ago

@william-ct No, that's what I'm talking about. If you add the only activity name ("TestActivity") to the manifest, then the list (inappActivityExclude) will store "TestActivity", while CoreMetaData.getCurrentActivityName() will return "com.your.company.name.TestActivity" and check will fail

AkimovAN commented 1 year ago

@william-ct Sorry, I mistyped the list name a bit. Of course, we were talking about the "blackListedActivity" list. But everything else is correct. I debugged it again with activity name in the manifest "android:value="SplashScreenActivity"" изображение

william-ct commented 1 year ago

@AkimovAN Ok, from your above sample, the following code will have

for (String blacklistedActivity : inappActivityExclude) {
            String currentActivityName = CoreMetaData.getCurrentActivityName();
            if (currentActivityName != null && currentActivityName.contains(blacklistedActivity)) {
                return false;
            }
}

blacklistedActivity string which has TestActivity whereas currentActivityName string has com.your.company.name.TestActivity, which is correct. The condition will be true or it will not fail because currentActivityName is not null AND currentActivityName contains blacklistedActivity string.

AkimovAN commented 1 year ago

@william-ct You are absolutely right, I understood what was wrong, thank you very much for your answers