3

enter image description hereI am trying to integrate my android project with freshchat SDK and it depends on LocalBroadcastManager but it's deprecated . So what should I use instead of LocalBroadcastManager in this scenario ?

   @Override
public void onCreate() {
    super.onCreate();
    initialiseFreshchat();
    registerBroadcastReceiver();
}


 private void registerBroadcastReceiver() {
                 IntentFilter intentFilterRestoreID = new IntentFilter(Freshchat.FRESHCHAT_USER_RESTORE_ID_GENERATED);
                 getLocalBroadcastManager().registerReceiver(restoreIdReceiver, intentFilterRestoreID);
             }
            
             public LocalBroadcastManager getLocalBroadcastManager() {
                 return LocalBroadcastManager.getInstance(getApplicationContext());
            
             }
            
            
            
             @Override
             public void onTerminate() {
                 super.onTerminate();
                 getLocalBroadcastManager().unregisterReceiver(restoreIdReceiver);
             }
            
             BroadcastReceiver restoreIdReceiver = new BroadcastReceiver() {
                 @Override
                 public void onReceive(Context context, Intent intent) {
                     
                     String restoreId = Freshchat.getInstance(getApplicationContext()).getUser().getRestoreId();
                     Toast.makeText(context, "Restore id: " + restoreId, Toast.LENGTH_SHORT).show();
                 }
            
             };
Omar Abdelazeem
  • 381
  • 2
  • 20
  • 1
    Since it looks like their code is what sends the local broadcasts, you would need to continue using `LocalBroadcastManager`, until such time as they update their SDK. – CommonsWare Jun 12 '22 at 16:33
  • I can't import LocalBroadcastManager in my project . How can I use it please @CommonsWare – Omar Abdelazeem Jun 12 '22 at 16:36
  • 1
    Strangely, their SDK does not seem to include `"androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"` (or another version of it) as a dependency. Add your own dependency on that and see if it works. If not, you probably need to [ask Freshchat for assistance](https://community.freshworks.com/freshchat-11252). – CommonsWare Jun 12 '22 at 16:41

0 Answers0