-
Notifications
You must be signed in to change notification settings - Fork 648
Closed
Labels
Description
I'm using firebase topic api as below:
val topics = originTopics.filter { it.matches(Regex("^[a-zA-Z0-9-_.~%]{1,900}")) }
val tasks = topics.map { topic ->
FirebaseMessaging.getInstance().subscribeToTopic(topic)
.addOnCompleteListener { task ->
var msg = "Subscribed"
if (!task.isSuccessful) {
msg = "Subscribe failed"
}
Timber.tag("FcmUtils").d("subscribeToTopic: $topic result $msg")
}.addOnFailureListener { e ->
Timber.tag("FcmUtils").d("subscribeToTopic: $topic failed: $e ")
}
}
Tasks.whenAll(tasks)
.addOnCompleteListener { allTasks ->
if (allTasks.isSuccessful) {
Timber.tag("FcmUtils").d("subscribeToTopics: All successful")
} else {
val failedTopics = topics.filterIndexed { index, _ ->
tasks[index].isCanceled
}
Timber.tag("FcmUtils").d("subscribeToTopics: all Failed to subscribe to ${failedTopics.joinToString()}")
}
}
but on some device . I get error: FirebaseMessaging Failed to sync topics. Won't retry sync. INVALID_PARAMETERS . The topic string is "type_period,lang_en,tz_115200" . This only happen on some device occasionally — it doesn’t always fail. How to fix this?