Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM push notifications for android devices are not working on MI and Letv mobiles

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.

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.

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.

like image 727
Shyam Avatar asked Nov 26 '16 01:11

Shyam


People also ask

Why am I not receiving push notifications on my Android?

Settings > Sounds & Vibration > Do Not Disturb: if this setting is enabled, Push Notifications will not be received. Make sure this is disabled. Settings > General > Background App Refresh: this setting allows the app to run in the background and must be turned on.

Why am I not getting notifications from MI?

Cause of Notifications Not Showing up on AndroidDo Not Disturb or Airplane Mode is on. Either system or app notifications are disabled. Power or data settings are preventing apps from retrieving notification alerts. Outdated apps or OS software can cause apps to freeze or crash and not deliver notifications.

How does GCM push notification work?

The first step in GCM is that a third-party server (such as an email server) sends a request to Google's GCM server. This server then sends the message to your device, through that open connection. The Android system looks at the message to determine which app it's for, and starts that app.


1 Answers

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.

like image 94
hardik9850 Avatar answered Oct 15 '22 13:10

hardik9850