인스턴트 메시징을 위해 Android 애플리케이션에서 FirebaseMessaging을 사용합니다.FirebaseMessaging Android 일부 메시지가 손실됩니다.
서버에서 장치 Android로 보내는 메시지의 경우 메시지가 손실되지 않습니다.
그러나 모바일에서 일부 메시지가 손실되는 서버에
...서버는 ACK 메시지를 수신하지만 다른 방향 (서버 이동)의 이동은 ACK를 수신하지 않습니다.
메시지의 약 30 %가 손실됩니다. 여러 메시지를 빨리 보내면 더 많은 손실 (40-60 %)이 발생합니다. 천천히 여러 메시지를 보내면 메시지가 10 % 손실됩니다.
메시지를 모바일로 보내면 FirebaseMessagingService에서 "onMessageSent"라는 메서드가 10 개의 메시지 중 막연하게 호출됩니다. 정상입니까? "onMessageSent는"한 번 즉시 메시지를 보낸으로 호출되지 않습니다 왜 ...
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
/** constante pour renvoyer la position GPS */
public static final String BROADCAST_FIREBASE_FILTER= "android.intent.action.MY_APP_FIREBASE";
private DatabaseHelper helper;
@Override
public void onCreate() {
super.onCreate();
}
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Notification method below.
DebugLog.logw(TAG,"MESSAGE RECEIVED");
String clickAction = remoteMessage.getNotification().getClickAction();
[..]
}
// [END receive_message]
/**
* Create and show a simple notification containing the received FCM message.
*
* @param messageBody FCM message body received.
*/
private void sendNotification(String title, String messageBody,Intent intent2) {
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
@Override
public void onDeletedMessages() {
super.onDeletedMessages();
DebugLog.logi(TAG, "onDeletedMessages");
}
@Override
public void onMessageSent(String s) {
super.onMessageSent(s);
DebugLog.logi(TAG, "onMessageSent = " + s);
}
@Override
public void onSendError(String s, Exception e) {
super.onSendError(s, e);
DebugLog.logi(TAG, "onSendError = " + s);
}
}
내 FragmentMessaging에서 내의 메소드 메시지 전송을 위해 :
public void sendMessage(Message msg){
DebugLog.logd("FragmentMessagerie","sendMessage msg = " + msg.getMsg());
if(textMessage.getText().length()>0) {
final Message message = msg;
AtomicInteger atomicInteger = new AtomicInteger();
FirebaseMessaging fm = FirebaseMessaging.getInstance();
RemoteMessage rm = new RemoteMessage.Builder(senderID)
.setMessageId("myApp_" + atomicInteger.incrementAndGet() + System.currentTimeMillis())
.addData("action", "chat")
.addData("destinataire", String.valueOf(contact.getId()))
.addData("emetteur",username)
.addData("texte",msg.getMsg())
.setTtl(0)
.build();
fm.send(rm); // appel à fireBase pour l'envoi du message
[..]
textMessage.setText("");
} else {
[..]
}
}
}
을내 질문은 :
보낼 때 메시지 (firebaseMessaging.send (remoteMessage)) Firebase는 서버로 메시지를 보내는 것을 처리해야한다.
메시지를 Firebase에 잘못 전송하는 Android입니까?
아니면 내 서버에 메시지를 잘못 전송하는 Firebase입니까?
서버에서 나는 모바일에 보낸 ACK 메시지를받습니다.
안드로이드에서 안드로이드에서 ACK 메시지를받지 못했습니다. 10 개의 메시지가 전송되었을 때 "onMessageSent"메서드가 10 회만 호출되었습니다. 정상입니까?
안드로이드에서 서버로 전송되는 메시지에 대해 ACK를 수신하려면 어떻게해야합니까? 내 장치에서?
미리 도움 주셔서 감사합니다.