【问题标题】:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent?定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一?
【发布时间】:2022-10-05 22:30:29
【问题描述】:

我正在使用 firebase 制作登录应用程序,我启用了电子邮件/密码和谷歌提供商都在小于 31 的 Api 上完美运行,但在高于谷歌工作的级别上,但电子邮件/密码没有,我不知道问题所在。 我试图做的事情: -将所有依赖项更新到最新版本。 -添加实现'androidx.work:work-runtime-ktx:2.7.0' - 以及我找到的每一个解决方案。enter image description here

class AuthenticationActivity : AppCompatActivity() {

private lateinit var binding: ActivityAuthenticationBinding
private val viewModel by viewModels<LoginViewModel>()

companion object {
    const val TAG = "LoginFragment"
    const val SIGN_IN_RESULT_CODE = 1001
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    binding = ActivityAuthenticationBinding.inflate(layoutInflater)
    val view = binding.root
    setContentView(view)

    binding.authButton.setOnClickListener { launchSignInFlow() }

    viewModel.authenticationState.observe(this) { authenticationState ->
        when (authenticationState) {
            LoginViewModel.AuthenticationState.AUTHENTICATED -> switchActivities()
            else -> Log.e(
                TAG,
                "Authentication state that doesn't require any UI change $authenticationState"
            )
        }
    }
}

private fun launchSignInFlow() {
    val providers = arrayListOf(
        EmailBuilder().build(), GoogleBuilder().build()
    )

    startActivityForResult(
        AuthUI.getInstance().createSignInIntentBuilder().setAvailableProviders(providers)
            .build(), AuthenticationActivity.SIGN_IN_RESULT_CODE
    )
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == SIGN_IN_RESULT_CODE) {
        val response = IdpResponse.fromResultIntent(data)
        if (resultCode == Activity.RESULT_OK) {
            startActivity(Intent(this@AuthenticationActivity, MyApp::class.java))
            finish()
            return
        } else {
            if (response == null) {
                Log.e("Login", "Login canceled by User")
                return
            }
            if (response.error!!.errorCode == ErrorCodes.NO_NETWORK) {
                Log.e("Login", "No Internet Connection")
                return
            }
            if (response.error!!.errorCode == ErrorCodes.UNKNOWN_ERROR) {
                Log.e("Login", "Unknown Error")
                return
            }
        }
        Log.e("Login", "Unknown sign in response")
    }
}

private fun switchActivities() {
    val switchActivityIntent = Intent(this, RemindersActivity::class.java)
    startActivity(switchActivityIntent)
}

}

private fun sendNotification(triggeringGeofences: List<Geofence>) {

    triggeringGeofences.forEach {
        val requestId = it.requestId

        val remindersRepository: ReminderDataSource by inject()
        //Interaction to the repository has to be through a coroutine scope
        CoroutineScope(coroutineContext).launch(SupervisorJob()) {
            //get the reminder with the request id
            val result = remindersRepository.getReminder(requestId)
            if (result is Result.Success<ReminderDTO>) {
                val reminderDTO = result.data
                //send a notification to the user with the reminder details
                sendNotification(
                    this@GeofenceTransitionsJobIntentService, ReminderDataItem(
                        reminderDTO.title,
                        reminderDTO.description,
                        reminderDTO.location,
                        reminderDTO.latitude,
                        reminderDTO.longitude,
                        reminderDTO.id
                    )
                )
            }
        }
    }
}

【问题讨论】:

  • 您在使用 Firebase 通知吗?
  • 使用通知,但不是来自 firebase。定期发送通知的乐趣
  • 你能把那个代码贴出来吗?
  • 在帖子中输入图片
  • Sir 图像不包含导致崩溃的代码。我想检查您已实现的通知代码。

标签: android firebase kotlin google-cloud-console


【解决方案1】:

这是旧版本的 Android 版 FirebaseUI 上的 issue。它已在version 8.0.2 中修复。请在 build.gradle 文件中更新您的依赖项:

implementation 'com.firebaseui:firebase-ui-auth:8.0.2'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-08
    • 2021-09-29
    • 1970-01-01
    • 2023-01-01
    • 2021-09-14
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    相关资源
    最近更新 更多