Skip to content
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

[Bug] "FirebaseMessaging.RequestPermissionAsync()" is incorrect. #1352

Closed
fanhonglin-t4f opened this issue Aug 16, 2023 · 1 comment
Closed
Labels
new New issue.

Comments

@fanhonglin-t4f
Copy link

fanhonglin-t4f commented Aug 16, 2023

[READ] For Firebase Unity SDK issues, please report to Firebase Unity open-source

Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.30f1, 2019.4.10f1, 2021.3.20f1, etc.
  • Firebase Unity SDK version: 9.0.0, 11.3.0
  • Source you installed the SDK: FirebaseMessaging.unitypackage (.unitypackage or Unity Package Manager)
  • Problematic Firebase Component: FirebaseMessaging (Auth, Database, etc.)
  • Other Firebase Components in use: None (Auth, Database, etc.)
  • Additional SDKs you are using: None (Facebook, AdMob, etc.)
  • Platform you are using the Unity editor on: Windows (Mac, Windows, or Linux)
  • Platform you are targeting: Android (iOS, Android, and/or desktop)
  • Scripting Runtime: Mono (Mono, and/or IL2CPP)

[REQUIRED] Please describe the issue here:

I'm trying to run messaging/testapp.
The logic of the code(FirebaseMessaging.RequestPermissionAsync()) is inconsistent with the comments.
The comment says "This will display the prompt to request permission"
image
But actually the prompt is not displayed at all

It happened on Android12, Android13, OPPO Rendo 9, Pixel 4.
(Android12 will pop up a prompt during the application startup phase, while Android13 will not pop up a prompt.)


So, is the comment of the method RequestPermissionAsync simply wrong? Should I manually implement the request permission prompt myself?

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
Yes
What's the issue repro rate? (eg 100%, 1/5 etc)
100%

What happened? How can we make the problem occur?
No prompt shown. Normal start.
This could be a description, log/console output, etc.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.
Just use quickstart-unity

Relevant Code:

Firebase.Sample.Messaging.UIHandler.InitializeFirebase

            // This will display the prompt to request permission to receive
            // notifications if the prompt has not already been displayed before. (If
            // the user already responded to the prompt, thier decision is cached by
            // the OS and can be changed in the OS settings).
            FirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(
                task => { LogTaskCompletion(task, "RequestPermissionAsync"); }
            );
@fanhonglin-t4f fanhonglin-t4f added the new New issue. label Aug 16, 2023
@a-maurice
Copy link
Contributor

So the issue is that RequestPermissionAsync is only meant to pull up the prompt on iOS. On Android (and desktop) it will immediately return as a success. I'll update the comment to make it clearer.

@firebase firebase locked and limited conversation to collaborators Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new New issue.
Projects
None yet
Development

No branches or pull requests

2 participants