CleverTap / clevertap-flutter

CleverTap Flutter SDK
Other
32 stars 44 forks source link

In-App message doesnt show in app, only receiving it as Push notification #158

Closed rajeshzmoke closed 1 year ago

rajeshzmoke commented 1 year ago

clevertap plugin clevertap_plugin: ^1.6.0

Template used on CT dashboard

Template:
Half Interstitial

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.7, on macOS 13.2.1 22D68 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.76.2)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

• No issues found!

Clicking on notfication gives the following logs, but In-App message is not shown

V/CleverTap(24883): PostAsyncSafely Task: testInappNotification starting on...pool-24-thread-1
V/CleverTap(24883): Received in-app via push payload: { "type" : "half-interstitial" , "bg" : "#ffffff" , "tablet" : false , "close" : true , "message" : { "text" : "TEsting In App message" , "color" : "#434761" , "replacements" : "TEsting In App message" , "og" : ""} , "title" : { "text" : "In app Message" , "color" : "#434761" , "replacements" : "In app Message" , "og" : ""} , "buttons" : [ ] , "media" : { } , "isMediaSourceRecommended" : false , "recommendedText" : { "text" : "" , "replacements" : "" , "og" : ""} , "mediaLandscape" : { } , "isMediaSourceRecommendedLandscape" : false , "recommendedTextLandscape" : { "text" : "" , "replacements" : "" , "og" : ""} , "hasPortrait" : true , "hasLandscape" : false , "rounded-borders" : false}
V/CleverTap:W44-949-5Z6Z(24883): InApp: Processing response
V/CleverTap:W44-949-5Z6Z(24883): controllerManager.getInAppFCManager() is NULL, not Updating InAppFC Limits
I/CleverTapResponse(24883): Done processing response!
V/CleverTap(24883): PostAsyncSafely Task: testInappNotification executed successfully on...pool-24-thread-1
V/CleverTap(24883): PostAsyncSafely Task: InAppResponse#processResponse starting on...pool-35-thread-1
V/CleverTap(24883): PostAsyncSafely Task: InappController#showNotificationIfAvailable starting on...pool-35-thread-1
V/CleverTap:W44-949-5Z6Z(24883): checking Pending Notifications
D/CleverTap:W44-949-5Z6Z(24883): Preparing In-App for display: {"type":"half-interstitial","bg":"#ffffff","tablet":false,"close":true,"message":{"text":"TEsting In App message","color":"#434761","replacements":"TEsting In App message","og":""},"title":{"text":"In app Message","color":"#434761","replacements":"In app Message","og":""},"buttons":[],"media":{},"isMediaSourceRecommended":false,"recommendedText":{"text":"","replacements":"","og":""},"mediaLandscape":{},"isMediaSourceRecommendedLandscape":false,"recommendedTextLandscape":{"text":"","replacements":"","og":""},"hasPortrait":true,"hasLandscape":false,"rounded-borders":false}
V/CleverTap(24883): PostAsyncSafely Task: InappController#prepareNotificationForDisplay starting on...pool-35-thread-1
V/CleverTap(24883): PostAsyncSafely Task: InappController#prepareNotificationForDisplay executed successfully on...pool-35-thread-1
V/CleverTap(24883): PostAsyncSafely Task: InappController#showNotificationIfAvailable executed successfully on...pool-35-thread-1
I/flutter (24883): didChangeAppLifecycleState AppLifecycleState.resumed ConnectivityResult.wifi
V/CleverTap(24883): PostAsyncSafely Task: InAppResponse#processResponse executed successfully on...pool-35-thread-1
V/CleverTap:W44-949-5Z6Z(24883): Attempting to show next In-App
V/CleverTap:W44-949-5Z6Z(24883): Not in foreground, queueing this In App
D/CleverTap:W44-949-5Z6Z(24883): Notification ready: {"type":"half-interstitial","bg":"#ffffff","tablet":false,"close":true,"message":{"text":"TEsting In App message","color":"#434761","replacements":"TEsting In App message","og":""},"title":{"text":"In app Message","color":"#434761","replacements":"In app Message","og":""},"buttons":[],"media":{},"isMediaSourceRecommended":false,"recommendedText":{"text":"","replacements":"","og":""},"mediaLandscape":{},"isMediaSourceRecommendedLandscape":false,"recommendedTextLandscape":{"text":"","replacements":"","og":""},"hasPortrait":true,"hasLandscape":false,"rounded-borders":false}
V/CleverTap:W44-949-5Z6Z(24883): Attempting to show next In-App
V/CleverTap:W44-949-5Z6Z(24883): Not in foreground, queueing this In App
I/flutter (24883): _platformCallHandler call beforeShow {}
shivamsharma2710 commented 1 year ago

Hi @rajeshzmoke

We'll check this internally and get back to you.

shivamsharma2710 commented 1 year ago

Hi @rajeshzmoke

This issue is expected for Android 12 and above if you have not catered the Notification trampolines handling.

Apps need to add the manual handling for android 12 onwards to inform the CleverTap SDK about the notification click and get the In-App message.

To achieve the same, add the following code in the onNewIntent() method of the Launcher/Main FlutterActivity:

class MainActivity : FlutterActivity() {

override fun onNewIntent(intent: Intent?) {
   super.onNewIntent(intent)

   // On Android 12, Raise notification clicked event when Activity is already running in activity backstack
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
       cleverTapDefaultInstance?.pushNotificationClickedEvent(intent!!.extras)
        }
    }
}

The same is referred in the CleverTap Android Push doc.

shivamsharma2710 commented 1 year ago

Closing this ticket. Feel free to reopen the issue if you have any further questions.

HAFIZkhan-source commented 11 months ago

what about java?

My MainActivity.java is extended using FlutterActivity class

e.x public class MainActivity extends FlutterActivity {}

How can I declare cleverTapDefaultInstance?.pushNotificationClickedEvent(intent!!.extras) in my activity?

shivamsharma2710 commented 11 months ago

Hi @HAFIZkhan-source

Please refer the doc on how to access the CleverTap Instance.

HAFIZkhan-source commented 11 months ago

@shivamsharma2710 The above doc was not helpful. My MainActivity is extended using FlutterActivity using Java and having the onCreate method only. So my doubt is what should I pass into cleverTapDefaultInstance?.pushNotificationClickedEvent() method parameter? like in kotlin we can pass intent!!.extras