簡體   English   中英

oppo,vivo 應用程序終止通知未出現在 android fcm 中

[英]oppo, vivo app kill notification not coming in android fcm

在摩托羅拉測試應用程序,當應用程序被殺死時,三星工作正常。 但是當我在體內測試應用程序時,如果應用程序被破壞,oppo 將無法工作。

 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:

 <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>

在 vivo 的情況下,我沒有收到消息,建議您向 oppo 提供任何幫助。

Infinix Note 5 (Android One-Oreo) 和 Oppo F9(Oreo) 在應用程序被殺死時不會收到推送通知,如果應用程序在后台或前台,它們可以正常工作。

當應用程序從最近的應用程序托盤中滑動時,使用(Oxygen OS、MIUI 等)的中文 ROM 您的應用程序將被終止(類似於強制停止)。 由於這個原因,像服務一樣在后台運行的每個任務,喬布斯都會被應用程序殺死。 即使是高優先級 FCM 也看不到中文 ROM 中的日光

實時問題:

1)您無法獲取用戶的位置。 因此,如果依賴於實時位置,則任何應用程序都無法正常運行

2) 您無法接收 FCM 高優先級通知

3)如果應用程序不在托盤中,則不會執行特定時間的任務/作業等等......

解決方案

用戶需要在應用設置中啟用自動啟動以保持后台服務/作業運行。默認情況下它是關閉的。要在我們可以使用的某些設備中執行此操作,

示例代碼

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

您可以進入設置>更多設置>權限管理(應用程序)>自動啟動打開應用開關。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM