zoho / SalesIQ-Mobilisten-ReactNative

Your mobile app's ideal live chat partner. Power up your mobile App with the SalesIQ Mobilisten SDK for React-Native.
https://mobilisten.io/
9 stars 11 forks source link

Push Notifications Not Working When App is Closed on Android #101

Open dieptang opened 4 days ago

dieptang commented 4 days ago

SDK Version: 8.0.5 Tested Environment: Android 10

Issue: Push notifications are not working when the app is fully closed (killed). However, notifications work fine when the app is kept open in the foreground or background.

SaleIQMessagingService.java

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.zoho.salesiqembed.ZohoSalesIQ;
import java.util.Map;

public class SaleIQMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map extras = remoteMessage.getData();
        ZohoSalesIQ.Notification.handle(this.getApplicationContext(), extras);
    }

    @Override
    public void onNewToken(String token) {
        // Pass true to test push notification from SalesIQ console
        ZohoSalesIQ.Notification.enablePush(token, false);
    }
}

AndroidManifest.xml:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_logo"
  android:allowBackup="false"
  android:usesCleartextTraffic="true"
  android:requestLegacyExternalStorage="true"
  android:theme="@style/AppTheme">

  <service android:exported="true" android:name=".SaleIQMessagingService">
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT"/>
      </intent-filter>
  </service>
</application>

Steps to Reproduce:

Launch the app and keep it open or in the background. Push notifications work as expected. Close the app completely (swipe away from recent apps). Try sending a push notification via Firebase or SalesIQ console. The notification is not received. Expected Behavior: Push notifications should be delivered even when the app is closed.

Actual Behavior: No push notifications are received when the app is closed.

Please let me know if there are any additional configurations or steps required to ensure push notifications are received when the app is closed.

bhahirathan-mb-11956 commented 4 days ago

Hi @dieptang ,

We apologize for the inconvenience caused. We have analyzed the code you have shared, and it looks fine.

Possible cases that might stop push notifications:

  1. In your app settings, check whether a battery optimization option is enabled that prevents your app from initiating the process when in the background.
  2. If you are testing with the test push notification from Brand settings, please pass true in ZohoSalesIQ.Notification.enablePush(token, true); or please initiate a new chat and try sending messages from that chat.

Additionally, it would be useful for debugging this case if you could share your portal, brand, and chat ID details with us at support@zohosalesiq.com. We will be happy to assist you.

Regards, Bhahirathan M Zoho SalesIQ.