Firebase push doesnt receive after init in other process

19 views Asked by At

in way of optimization i decide to init push in other process, its works well in android 10 and higher but push isnt showen in lower versions of android

i need it works well in all android versions

this is my manifest code

<receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:process=":pushprocess"
            tools:node="replace">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>

        <service
            android:name="FirebaseMessagingService"
            android:exported="false"
            tools:node="replace"
            android:process=":pushprocess">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
1

There are 1 answers

0
Dan Gerchcovich On

By "other process" I take it you mean a coroutine. Is the firebase notification doing something on the app? Does it present an in-app message?

If it does, then you need to make sure that the couroutine that receives the firebase notification marshals the presentation logic on the main thread.

So in your case do this (an example to show the principle):

fun receiveFirebaseMessage(data: String){

   withContext(Dispatchers.Main) {
        //present an in-app message or any UI logic for the app here
   } 
}