oppo,vivo app终止通知不在android fcm中出现 [英] oppo, vivo app kill notification not coming in android fcm

查看:175
本文介绍了oppo,vivo app终止通知不在android fcm中出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Motorola中测试应用程序,当该应用程序被杀死时,三星可以正常工作.但是当我在体内测试应用程序时,oppo在应用程序被破坏的情况下无法正常工作.

Testing app in motorola , samsung working fine when app is killed. but when i test app in vivo, oppo not working in case of app is destroyed.

 public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.e(TAG, "From: " + remoteMessage.getFrom());

    if (remoteMessage == null)
        return;

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
        //  handleNotification(remoteMessage.getNotification().getBody());
    }

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());

        try {
            JSONObject json = new JSONObject(remoteMessage.getData().toString());
            handleDataMessage(json);
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }
}

Android清单xml:

Android Manifest xml:

 <service
        android:name="notification.MyFirebaseMessagingService"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service android:name="notification.MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>

关于体内情况,我没有收到任何消息,建议您给予任何帮助.

I am not getting message in case of vivo, oppo any help would be recommended.

推荐答案

Infinix Note 5(Android One-Oreo)和Oppo F9(Oreo)没有安装 如果应用程序被杀死,则推送通知,如果应用程序在 背景或前景.

Infinix Note 5 (Android One- Oreo) and Oppo F9(Oreo) are not getting push notification if app is killed, they work fine if app is in background or foreground.

从最近的应用程序托盘中刷过应用程序后,使用(氧气操作系统,MIUI等)的中文ROM会终止(类似于强制停止).由于这个原因,每项任务都会在后台运行,例如服务,因此乔布斯会被该应用杀死.即使是高优先级FCM也看不到中文ROM中的日光

Chinese ROMs using (Oxygen OS, MIUI etc) when the apps are swiped from the recent app tray your app gets terminated ( similar to Force Stop). And due to this every task running in the background like Services, Jobs gets killed with the app. Even High priority FCM doesn’t see the daylight in Chinese ROMs

实时问题:

Real time problems :

1)您无法获取用户的位置.因此,如果依赖于实时位置,则没有任何应用能够正常运行

1) You can’t fetch location of the user. So, no app would work properly if it depends on real-time location

2)您无法接收FCM高优先级通知

2) You can’t recevie the FCM high priority notifications

3)如果应用不在纸盘中,并且还有更多……,将不会执行特定于时间的任务/作业.

3) No time specific task/Job would execute if app is not in the tray and many more ….

解决方案

用户需要在应用程序的设置中启用自动启动功能,以保持后台服务/作业的运行.默认情况下,该功能处于关闭状态.要在我们可以使用的某些设备中执行此操作,

user needs to enable auto start in settings for app to keep background service/Job running.By default it is off.To do this in some of the devices we can use,

示例代码

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = new Intent();

    String manufacturer = android.os.Build.MANUFACTURER;

    switch (manufacturer) {

        case "xiaomi":
            intent.setComponent(new ComponentName("com.miui.securitycenter",
                    "com.miui.permcenter.autostart.AutoStartManagementActivity"));
            break;
        case "oppo":
            intent.setComponent(new ComponentName("com.coloros.safecenter",
                    "com.coloros.safecenter.permission.startup.StartupAppListActivity"));

            break;
        case "vivo":
            intent.setComponent(new ComponentName("com.vivo.permissionmanager",
                    "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
            break;
    }

  List<ResolveInfo> arrayList =  getPackageManager().queryIntentActivities(intent,
          PackageManager.MATCH_DEFAULT_ONLY);

    if (arrayList.size() > 0) {
        startActivity(intent);
    }
}

}

来源:https://stackoverflow.com /questions/52849445/some-oreo-devices-are-not-getting-push-notification/52943903#52943903

这篇关于oppo,vivo app终止通知不在android fcm中出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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