Skip to content

Fix the issue where third-party apps encounter "Invalid argument for … #2954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public final class GcmConstants {

public static final String ERROR_SERVICE_NOT_AVAILABLE = "SERVICE_NOT_AVAILABLE";

public static final String ERROR_INVALID_FID = "Invalid argument for the given fid";

public static final String INSTANCE_ID_SCOPE_GCM = "GCM";

public static final String GCMID_INSTANCE_ID = "google.com/iid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,21 @@ private suspend fun ensureAppRegistrationAllowed(context: Context, database: Gcm
}

suspend fun completeRegisterRequest(context: Context, database: GcmDatabase, request: RegisterRequest, requestId: String? = null): Bundle = suspendCoroutine { continuation ->
PushRegisterManager.completeRegisterRequest(context, database, requestId, request) { continuation.resume(it) }
PushRegisterManager.completeRegisterRequest(context, database, requestId, request) {
val errorMsg = it.getString(EXTRA_ERROR)
Log.w(TAG, "completeRegisterRequest error: $errorMsg")
if (errorMsg == PushRegisterManager.attachRequestId(ERROR_INVALID_FID, requestId) && !request.delete) {
Log.d(TAG, "completeRegisterRequest register error, You need to call delete first before you can re-register")
request.delete = true
request.response
request.delete = false
PushRegisterManager.completeRegisterRequest(context, database, requestId, request) { result ->
continuation.resume(result)
}
} else {
continuation.resume(it)
}
}
}

private val Intent.requestId: String?
Expand Down