Android,推FCM

时间:2018-02-04 14:02:38

标签: android firebase-cloud-messaging push

我需要有关android中fcm推送问题的帮助。 当我收到手机上的推送时,我无法在我放入FirebaseMessagingService的日志中收到它。

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

        if (remoteMessage == null)
            return;

        //Check if the message contains data
        // 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());
            }
        }

        //Check if the message contains notification

        if (remoteMessage.getNotification() != null) {
            Log.e(TAG, "Mesage body:" + remoteMessage.getNotification().getBody());
            sendNotification(remoteMessage.getNotification().getBody());
        }
    }

0 个答案:

没有答案