chat21 / chat21-android-sdk

Android Chat SDK built on Firebase
http://www.chat21.org
MIT License
233 stars 98 forks source link

Messaging Activity not launching from Notifications #31

Open Sakpal opened 5 years ago

Sakpal commented 5 years ago

When app is in killed state and user receives a chat, a notification is shown. When tapped on that notification, nothing happens...

Tried it on Android 7.0 and 8.1

One observation is that if the app is in foreground and you get a message notification, kill the app and now tap on the notification. It works.

Sakpal commented 5 years ago

Seems like the issue was with incorrect click_action setting. This fixes the app launching but crashes on the launch.

Attached crashlog screen shot 2019-01-16 at 9 30 14 pm

andrealeo83 commented 5 years ago

try to update your chat21-cloud-function code. https://github.com/chat21/chat21-cloud-functions

Sakpal commented 5 years ago

Hi @andrealeo83 ,

Will give it a try and update you.

nakul-kabra commented 5 years ago

Facing the same issue. Tried updating cloud function, still it did not help. What exactly to fix in Cloud Functions?

andrealeo83 commented 5 years ago

Cloud Functions now send different Click_action for each devices (ios, android, ionic): This is the code: https://github.com/chat21/chat21-cloud-functions/blob/master/functions/push-notification.js

   var clickAction = "NEW_MESSAGE";
        var icon = "ic_notification_small";
        if (platform=="ionic"){
            clickAction = "https://support.tiledesk.com/chat/";
            icon = "/chat/assets/img/icon.png"
        }
PlutusM commented 5 years ago

Any Solution, Facing same problem. i have setup Ionic web and android app sdk.

When i try to chat from ionic web to android. i am getting notification in android but when i try to open it nothing happening.

Here is logs i receive when i tap to notification :

2019-07-28 15:54:48.075 1818-1818/com.testing.app E/FirebaseMessaging: Notification pending intent canceled 2019-07-28 15:54:48.080 13718-16824/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 30537465 , only wrote 30535920 2019-07-28 15:54:48.097 1818-1818/com.testing.app W/FirebaseMessaging: Error while parsing timestamp in GCM event java.lang.NumberFormatException: s == null at java.lang.Integer.parseInt(Integer.java:577) at java.lang.Integer.parseInt(Integer.java:650) at com.google.firebase.messaging.zzb.zzb(Unknown Source:81) at com.google.firebase.messaging.zzb.zzd(Unknown Source:116) at com.google.firebase.messaging.FirebaseMessagingService.zzc(Unknown Source:44) at com.google.firebase.iid.zzf.zza(Unknown Source:30) at com.google.firebase.iid.zzh.zzc(Unknown Source:77) at com.google.firebase.iid.zzh.zza(Unknown Source:29) at com.google.firebase.iid.FirebaseInstanceIdReceiver.zza(Unknown Source:139) at com.google.firebase.iid.FirebaseInstanceIdReceiver.onReceive(Unknown Source:19) at android.app.ActivityThread.handleReceiver(ActivityThread.java:3379) at android.app.ActivityThread.access$1200(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Looking forward for solution, Thanks..

PlutusM commented 5 years ago

Any Solution, Facing same problem. i have setup Ionic web and android app sdk.

When i try to chat from ionic web to android. i am getting notification in android but when i try to open it nothing happening.

Here is logs i receive when i tap to notification :

2019-07-28 15:54:48.075 1818-1818/com.testing.app E/FirebaseMessaging: Notification pending intent canceled 2019-07-28 15:54:48.080 13718-16824/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 30537465 , only wrote 30535920 2019-07-28 15:54:48.097 1818-1818/com.testing.app W/FirebaseMessaging: Error while parsing timestamp in GCM event java.lang.NumberFormatException: s == null at java.lang.Integer.parseInt(Integer.java:577) at java.lang.Integer.parseInt(Integer.java:650) at com.google.firebase.messaging.zzb.zzb(Unknown Source:81) at com.google.firebase.messaging.zzb.zzd(Unknown Source:116) at com.google.firebase.messaging.FirebaseMessagingService.zzc(Unknown Source:44) at com.google.firebase.iid.zzf.zza(Unknown Source:30) at com.google.firebase.iid.zzh.zzc(Unknown Source:77) at com.google.firebase.iid.zzh.zza(Unknown Source:29) at com.google.firebase.iid.FirebaseInstanceIdReceiver.zza(Unknown Source:139) at com.google.firebase.iid.FirebaseInstanceIdReceiver.onReceive(Unknown Source:19) at android.app.ActivityThread.handleReceiver(ActivityThread.java:3379) at android.app.ActivityThread.access$1200(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Looking forward for solution, Thanks..

I solved this issue by upgrading firebase messaging : implementation 'com.google.firebase:firebase-messaging:17.3.4'

I got another issue When i click on notification : E/FirebaseMessaging: Notification pending intent canceled

PlutusM commented 5 years ago

Any Solution, Facing same problem. i have setup Ionic web and android app sdk. When i try to chat from ionic web to android. i am getting notification in android but when i try to open it nothing happening. Here is logs i receive when i tap to notification : 2019-07-28 15:54:48.075 1818-1818/com.testing.app E/FirebaseMessaging: Notification pending intent canceled 2019-07-28 15:54:48.080 13718-16824/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 30537465 , only wrote 30535920 2019-07-28 15:54:48.097 1818-1818/com.testing.app W/FirebaseMessaging: Error while parsing timestamp in GCM event java.lang.NumberFormatException: s == null at java.lang.Integer.parseInt(Integer.java:577) at java.lang.Integer.parseInt(Integer.java:650) at com.google.firebase.messaging.zzb.zzb(Unknown Source:81) at com.google.firebase.messaging.zzb.zzd(Unknown Source:116) at com.google.firebase.messaging.FirebaseMessagingService.zzc(Unknown Source:44) at com.google.firebase.iid.zzf.zza(Unknown Source:30) at com.google.firebase.iid.zzh.zzc(Unknown Source:77) at com.google.firebase.iid.zzh.zza(Unknown Source:29) at com.google.firebase.iid.FirebaseInstanceIdReceiver.zza(Unknown Source:139) at com.google.firebase.iid.FirebaseInstanceIdReceiver.onReceive(Unknown Source:19) at android.app.ActivityThread.handleReceiver(ActivityThread.java:3379) at android.app.ActivityThread.access$1200(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Looking forward for solution, Thanks..

I solved this issue by upgrading firebase messaging : implementation 'com.google.firebase:firebase-messaging:17.3.4'

I got another issue When i click on notification : E/FirebaseMessaging: Notification pending intent canceled

Got Solution,

On Cloud Functions https://github.com/chat21/chat21-cloud-functions/blob/master/functions/push-notification.js

Dont Pass : click_action in notification Like below :

const payload = {
        notification: {
            title: message.sender_fullname,
            body: text,
            icon : icon,
            sound : "default",
          //   click_action: clickAction,
            //click_action: "https://support.tiledesk.com/chat/",   // uncomment for intent filter in your custom project
            //click_action: "NEW_MESSAGE",   // uncomment for intent filter in your custom project

            // "content-available": "1",
            "content_available": "true",
            badge : "1"
        },

it will take main activity from app.

shashankshahplutus commented 3 years ago

@andrealeo83 @Sakpal Do we need to enable anything in our code for sending and receiving push notifications? We have implemented chat21-SDK successfully we are able to get the message on another end as well but notifications are not working on android and ios devices. I see there is js under the functions/push-notification.js seems it should work but it is not. am I doing something wrong or missing any configuration? please help! thanks in advance!