{"record":{"id":"0cdc7299fd990a2b","repo":"microg/GmsCore","slug":"push-permission-not-granted-to-packagename","errorCode":null,"errorMessage":"Push permission not granted to $packageName","messagePattern":"Push permission not granted to \\$packageName","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt","lineNumber":73,"sourceCode":"suspend fun ensureAppRegistrationAllowed(context: Context, database: GcmDatabase, packageName: String) {\n    if (!GcmPrefs.get(context).isEnabled) throw RuntimeException(\"GCM disabled\")\n    val app = database.getApp(packageName)\n    if (app == null && GcmPrefs.get(context).confirmNewApps) {\n        val accepted: Boolean = suspendCoroutine { continuation ->\n            val i = Intent(context, AskPushPermission::class.java)\n            i.putExtra(AskPushPermission.EXTRA_REQUESTED_PACKAGE, packageName)\n            i.putExtra(AskPushPermission.EXTRA_RESULT_RECEIVER, object : ResultReceiver(null) {\n                override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {\n                    continuation.resume(resultCode == Activity.RESULT_OK)\n                }\n            })\n            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)\n            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)\n            i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)\n            context.startActivity(i)\n        }\n        if (!accepted) {\n            throw RuntimeException(\"Push permission not granted to $packageName\")\n        }\n    } else if (app?.allowRegister == false) {\n        throw RuntimeException(\"Push permission not granted to $packageName\")\n    }\n}\n\nsuspend fun completeRegisterRequest(context: Context, database: GcmDatabase, request: RegisterRequest, requestId: String? = null): Bundle = suspendCoroutine { continuation ->\n    PushRegisterManager.completeRegisterRequest(context, database, requestId, request) {\n        val errorMsg = it.getString(EXTRA_ERROR)\n        Log.w(TAG, \"completeRegisterRequest error: $errorMsg\")\n        if (errorMsg == PushRegisterManager.attachRequestId(ERROR_INVALID_FID, requestId) && !request.delete) {\n            Log.d(TAG, \"completeRegisterRequest register error, You need to call delete first before you can re-register\")\n            request.delete = true\n            request.response\n            request.delete = false\n            PushRegisterManager.completeRegisterRequest(context, database, requestId, request) { result ->\n                continuation.resume(result)\n            }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt#L55-L91","documentation":"PushRegisterService.ensureAppRegistrationAllowed throws RuntimeException with this message when the app is unknown to the GCM database, the user declined (or did not respond to) the push-permission prompt, so registration is aborted for a package lacking push permission.","triggerScenarios":"Thrown at play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Grant the app notification/push permission (via the AskPushPermission flow or system settings)","Deny registration gracefully by replying with a permission error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}