Android 设备的 GCM 推送通知不适用于 MI 和 Letv 手机 [英] GCM push notifications for android devices are not working on MI and Letv mobiles

查看:85
本文介绍了Android 设备的 GCM 推送通知不适用于 MI 和 Letv 手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在向所有安卓设备发送 GCM 推送通知时遇到了问题.我们正在 Ionic 平台上开发一个应用程序,并使用名为 cordova push 的插件来推送通知.设备正在向 gcm 注册并接收设备令牌.我正在使用 3 台设备来测试 Moto g4 plus、MI4 和 Letv.

We are facing the problem in sending GCM push notifications to all the android devices. We are developing an app on Ionic platform and using the plugin called cordova push for the push notifications. The device is registering with gcm and receiving device token. I am using 3 devices to test Moto g4 plus, MI4 and Letv.

问题是当应用被终止时,推送通知会到达 moto g4 plus 设备,但不会到达 MI 和 Letv 设备.小米和乐视设备也只有在应用程序处于前台或后台时才会收到通知.

The problem is push notification is reaching to moto g4 plus device but not to MI and Letv devices when the app is killed. MI and Letv devices are also receiving the notification only when the app is in the foreground or background.

我也收到了来自 gcm 的交付收据,这些收据也已交付给应用程序终止案例中的所有设备.

I am receiving delivery receipts from gcm as delivered to all the devices in the app killed case too.

请提出一些解决方案来克服这个问题.谢谢你.

Please suggest some solution to overcome this problem. Thank you.

推荐答案

我也遇到了这个问题我的小米手机需要自动启动权限"才能在应用被杀死时接收 FCM 通知,您需要在此列表中移动您的应用.

I also faced this issue I have Xiaomi mobile that needs 'Autostart Permission' to receive FCM Notification when app is killed,you need to move your app in this list.

对于小米设备,您可以向用户请求此权限在此处查看答案

For Xiaomi device you can ask user for this permission Check the answer here

    String xiaomi = "Xiaomi";
    final String CALC_PACKAGE_NAME = "com.miui.securitycenter";
    final String CALC_PACKAGE_ACITIVITY = "com.miui.permcenter.autostart.AutoStartManagementActivity";
    if (deviceManufacturer.equalsIgnoreCase(xiaomi)) {
        DisplayUtils.showDialog(activity, "Ask for permission", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                try {
                    Intent intent = new Intent();
                    intent.setComponent(new ComponentName(CALC_PACKAGE_NAME, CALC_PACKAGE_ACITIVITY));
                    activity.startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Logger.e(TAG, "Failed to launch AutoStart Screen ", e);
                } catch (Exception e) {
                    Logger.e(TAG, "Failed to launch AutoStart Screen ", e);
                }
            }
        }, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
    }

至于乐视手机,我还没有检查过.如果你解决了,请告诉我.

And as for Letv mobile i haven't checked it.If you have solved it then do tell me.

这篇关于Android 设备的 GCM 推送通知不适用于 MI 和 Letv 手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆