microg/GmsCore · error · RuntimeException

GCM disabled

Error message

GCM disabled

What it means

PushRegisterService.ensureAppRegistrationAllowed throws RuntimeException("GCM disabled") when GCM is turned off in microG preferences (GcmPrefs.isEnabled is false). The failing condition is a configuration/state issue, not a bad argument: push registration is requested while the user or configuration disabled GCM entirely.

Source

Thrown at play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt:56

            val continued = AtomicBoolean(false)
            intent.putExtra(CheckinService.EXTRA_RESULT_RECEIVER, object : ResultReceiver(null) {
                override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
                    if (continued.compareAndSet(false, true)) continuation.resume(resultData ?: Bundle.EMPTY)
                }
            })
            ForegroundServiceContext(context).startService(intent)
            Handler().postDelayed({
                if (continued.compareAndSet(false, true)) continuation.resume(Bundle.EMPTY)
            }, 10000L)
        }
        if (resultData.getLong(CheckinService.EXTRA_NEW_CHECKIN_TIME, 0L) + lastCheckin == 0L) {
            throw RuntimeException("No checkin available")
        }
    }
}

suspend fun ensureAppRegistrationAllowed(context: Context, database: GcmDatabase, packageName: String) {
    if (!GcmPrefs.get(context).isEnabled) throw RuntimeException("GCM disabled")
    val app = database.getApp(packageName)
    if (app == null && GcmPrefs.get(context).confirmNewApps) {
        val accepted: Boolean = suspendCoroutine { continuation ->
            val i = Intent(context, AskPushPermission::class.java)
            i.putExtra(AskPushPermission.EXTRA_REQUESTED_PACKAGE, packageName)
            i.putExtra(AskPushPermission.EXTRA_RESULT_RECEIVER, object : ResultReceiver(null) {
                override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
                    continuation.resume(resultCode == Activity.RESULT_OK)
                }
            })
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
            i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
            context.startActivity(i)
        }
        if (!accepted) {
            throw RuntimeException("Push permission not granted to $packageName")
        }

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Enable cloud messaging in microG settings
  2. Catch the exception and reply with the appropriate registration error to the requesting app
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/c2cbebfc95619ecb. Report an issue: GitHub.