WorkManager not working for Baidu Push SDK

176 views Asked by At

I am using Baidu Push SDK in my project. I created a broadcast receiver to receive Baidu notifications which extends PushMessageReceiver. Whenever a notification is received I perform a one-time work manager request to upload the event to our server. As the broadcast receiver runs in another process I get below exception

java.lang.IllegalStateException: WorkManager is not initialized properly.  You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.

Can someone please help me with the solution to perform my WorkManager request successfully?

Thanks in advance.

1

There are 1 answers

0
Anil Gupta On BEST ANSWER

WorkManager is failing because Baidu Push works on a different process and WorkManager is not initialized in Baidu's process. You need to do two things, first, initialize WorkManager by wrapping it inside the condition which checks if the application is in the main process. It will avoid the WorkManager error you get. Second, you need to create a custom BroadcastReceiver to which you will be sending broadcasts when you get a notification in Baidu's BroadcastReceiver.

Hope this will solve your problem.