Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Message Service

i'm creating one application where i'm using fcm. it's work fine on some device but in some device like OPPO, RED-MI 5 PRO message not receiving after app killed. so what i have to do make sure message received every time on every device.

like image 489
kishan hadiyal Avatar asked Mar 15 '26 16:03

kishan hadiyal


1 Answers

so with Chinese Devices there are lot of issues with handling app services in background.

It works fine in stock roms but when it comes to customized ROM then there are lot of issues because the chinese devices restricts apps to be used in background.

So, apps like Whatsapp,Facebook or any big firm apps are whitelisted by these custom ROMs. But for new apps you can make the app accessible in background. When you swipe the app from app tray it considers it as Force Quit. It won't even run any Jobs, Task Scheduled.

What you can do is, Ask Used to Manual white list the app using,

        val intent = Intent()
        val manufacturer = android.os.Build.MANUFACTURER
        when {
            "xiaomi".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")
            "oppo".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")
            "vivo".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")
            "Letv".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")
            "Honor".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")
        }
        val list = applicationContext.packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
        if (list.size > 0) {
            applicationContext.startActivity(intent)
        }

With tech savvy users it might even work but don’t be surprised if you don’t get much far with this technique.

I too faced this issue. To get a detailed explanation on this refer here

like image 154
Himanshu Avatar answered Mar 17 '26 08:03

Himanshu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!