Skip to content
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

Android: notification is not come (+ crash happened) when app process is killed #743

Open
AliakseiZhukouski opened this issue Mar 18, 2023 · 2 comments

Comments

@AliakseiZhukouski
Copy link

  1. Is the bug present in the demo Chat SDK project?
    dependencies are:
    sdk.chat:firebase-app:5.4.2"
    sdk.chat:pro-firebase-last-online:5.4.2"

  2. What modifications have you made to the Chat SDK?

  3. Android Version:
    Android 10 (API 29)

  4. Steps taken to reproduce the problem:

  1. create thread 1 by 1 (using user firebase id)
  2. user 1 being in foreground from UI (chat details) send message to thread
  3. user 2 being in background (app process was intentionally killed by swiping up from recent) does not get any notification and from time to time get crash (in 50% of cases) - crash output is below
  1. Expected result:
    Application being in background (when process was killed swiping up from recents) should get notification

  2. Actual result:
    Application is not get any notification and sometimes can even crashes (being in background and killed as process).
    In the logcat output we can see the next crash
    03-18 19:37:39.418 E/AndroidRuntime( 4883): java.lang.RuntimeException: Unable to start receiver sdk.chat.core.push.DefaultBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'org.greenrobot.greendao.query.QueryBuilder sdk.chat.core.dao.DaoSession.queryBuilder(java.lang.Class)' on a null object reference
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.app.ActivityThread.handleReceiver(ActivityThread.java:4238)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.app.ActivityThread.access$1700(ActivityThread.java:274)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2113)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.os.Handler.dispatchMessage(Handler.java:107)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.os.Looper.loop(Looper.java:237)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.app.ActivityThread.main(ActivityThread.java:8167)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at java.lang.reflect.Method.invoke(Native Method)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'org.greenrobot.greendao.query.QueryBuilder sdk.chat.core.dao.DaoSession.queryBuilder(java.lang.Class)' on a null object reference
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at sdk.chat.core.session.StorageManager.fetchEntityWithEntityID(StorageManager.java:162)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at sdk.chat.core.session.StorageManager.fetchThreadWithEntityID(StorageManager.java:209)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at sdk.chat.core.push.BaseBroadcastHandler.onReceive(BaseBroadcastHandler.java:34)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at sdk.chat.core.push.DefaultBroadcastReceiver.onReceive(DefaultBroadcastReceiver.java:18)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): at android.app.ActivityThread.handleReceiver(ActivityThread.java:4229)
    03-18 19:37:39.418 E/AndroidRuntime( 4883): ... 8 more

  3. Comments:

@bensmiley
Copy link
Contributor

I have investigated this and I'm not able to reproduce the issue. I would need a reliable way to reproduce it to go further.

@shjman
Copy link

shjman commented Jul 26, 2023

you can try to add this

if (!ChatSDK.db().isDatabaseOpen) {
        val currentUserId = ChatSDK.auth().currentUserEntityID
        if (currentUserId != null) {
            try {
                ChatSDK.db().openDatabase(currentUserId)
            } catch (e: Exception) {
                Log.e...
            }
        }
    }
after a moment when you call ChatSDK.builder()... .activate(context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants