Skip to content

ClassCastException on clicking Notification #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shashikantdurge opened this issue Dec 1, 2020 · 11 comments
Closed

ClassCastException on clicking Notification #26

shashikantdurge opened this issue Dec 1, 2020 · 11 comments
Assignees
Labels
issue under deployment Will be released in the next release

Comments

@shashikantdurge
Copy link

I'm using Custom MyFirebaseMessagingService


class MyFirebaseMessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(message: RemoteMessage) {
        try {
            if (message.data.size > 0) {
                val extras = Bundle()
                for ((key, value) in message.data) {
                    extras.putString(key, value)
                }
                Log.e("TAG", "onReceived Mesaage Called")
                val info = CleverTapAPI.getNotificationInfo(extras)
                if (info.fromCleverTap) {
                    CleverTapAPI.createNotification(applicationContext, extras)
                }
            }
        } catch (t: Throwable) {
            Log.d("MYFCMLIST", "Error parsing FCM message", t)
        }
    }
}

StackTrace:

2020-12-01 16:41:39.558 5787-5787/com.leher E/CleverTapPlugin: Exception while running on main thread - 
2020-12-01 16:41:39.561 5787-5787/com.leher W/System.err: java.lang.ClassCastException: com.leher.App cannot be cast to android.app.Activity
2020-12-01 16:41:39.563 5787-5787/com.leher W/System.err:     at com.clevertap.clevertap_plugin.CleverTapPlugin.runOnMainThread(CleverTapPlugin.java:1476)
2020-12-01 16:41:39.565 5787-5787/com.leher W/System.err:     at com.clevertap.clevertap_plugin.CleverTapPlugin.invokeMethodOnUiThread(CleverTapPlugin.java:1099)
2020-12-01 16:41:39.566 5787-5787/com.leher W/System.err:     at com.clevertap.clevertap_plugin.CleverTapPlugin.onNotificationClickedPayloadReceived(CleverTapPlugin.java:634)
2020-12-01 16:41:39.568 5787-5787/com.leher W/System.err:     at com.clevertap.android.sdk.CleverTapAPI.pushNotificationClickedEvent(CleverTapAPI.java:3265)
2020-12-01 16:41:39.569 5787-5787/com.leher W/System.err:     at com.clevertap.android.sdk.CleverTapAPI.handleNotificationClicked(CleverTapAPI.java:978)
2020-12-01 16:41:39.571 5787-5787/com.leher W/System.err:     at com.clevertap.android.sdk.pushnotification.CTPushNotificationReceiver.onReceive(CTPushNotificationReceiver.java:38)
2020-12-01 16:41:39.572 5787-5787/com.leher W/System.err:     at android.app.ActivityThread.handleReceiver(ActivityThread.java:3507)
2020-12-01 16:41:39.573 5787-5787/com.leher W/System.err:     at android.app.ActivityThread.access$1400(ActivityThread.java:207)
2020-12-01 16:41:39.574 5787-5787/com.leher W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1759)
2020-12-01 16:41:39.575 5787-5787/com.leher W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
2020-12-01 16:41:39.576 5787-5787/com.leher W/System.err:     at android.os.Looper.loop(Looper.java:193)
2020-12-01 16:41:39.577 5787-5787/com.leher W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6863)
2020-12-01 16:41:39.578 5787-5787/com.leher W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-12-01 16:41:39.579 5787-5787/com.leher W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
2020-12-01 16:41:39.580 5787-5787/com.leher W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@darshanclevertap
Copy link
Contributor

@shashikantdurge Which version are you on?

@shashikantdurge
Copy link
Author

clevertap_plugin: 1.2.0

@shashikantdurge
Copy link
Author

@darshanclevertap This is happening when the app is killed (Not in the Android stack).
It works fine when the app is in foreground and background.

@darshanclevertap
Copy link
Contributor

Sorry for the delay @shashikantdurge Thanks for bringing this up, we'll try to reproduce it on our end and fix this in the next version

@darshanclevertap
Copy link
Contributor

darshanclevertap commented Dec 15, 2020

@shashikantdurge Are you able to receive Push Notifications when the app is in the killed state when you're using the Firebase plugin? Or are you using your own Message Receiver in Android?

@shashikantdurge
Copy link
Author

shashikantdurge commented Dec 15, 2020 via email

@shashikantdurge
Copy link
Author

If you need any help in reproducing, I can help @darshanclevertap

@darshanclevertap
Copy link
Contributor

@shashikantdurge Yes, can you give me the steps. That would help a lot

@shashikantdurge
Copy link
Author

  1. Integrate Firebase messaging
  2. If the project is created before 1.12, Follow https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
  3. Integrate CleverTap plugin
  4. Integrate https://pub.dev/packages/flutter_local_notifications (Optional may be)
  5. Follow instructions from https://developer.clevertap.com/docs/using-fcm-version-1800-and-above

@darshanclevertap
Copy link
Contributor

@shashikantdurge Thank you for the steps. I'll try and reproduce this on my end once and report back here soon

@darshanclevertap darshanclevertap self-assigned this Dec 17, 2020
darshanclevertap added a commit that referenced this issue Dec 28, 2020
…thods, also adds fix for #26 passing callback using Main Looper to avoid NPE in case of no Activity context, updates CHANGELOG & README
@darshanclevertap darshanclevertap added the under deployment Will be released in the next release label May 19, 2021
@darshanclevertap
Copy link
Contributor

This has been fixed in CT Flutter Plugin v1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue under deployment Will be released in the next release
Projects
None yet
Development

No branches or pull requests

2 participants