firebase/quickstart-unity

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

fanhonglin-t4f opened this issue · 1 comments

[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"); }
            );

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.