firebase / firebase/firebase-cpp-sdk

[Bug] Cannot use provisional notification permissions with FCM on iOS

Offen
#1,227 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: messaging type: feature request
Vorherrschende Sprache
C++
Sterne
326
Forks
137
Ø Merge
3 T. 9 Std.
Gemergte PRs (30 T.)
5

Beschreibung

### [REQUIRED] Please fill in the following fields:

* Pre-built SDK from the [website](https://firebase.google.com/download/cpp) or open-source from this repo: built from sources
* Firebase C++ SDK version: 10.4.0
* Problematic Firebase Component: Cloud Messaging
* Other Firebase Components in use: n/a
* Platform you are using the C++ SDK on: MacOS 13.2.1 (22D68)
* Platform you are targeting: iOS

### [REQUIRED] Please describe the issue here:

FCM does not register with APNS when suppressing the permission prompt during FCM initialization.

Why suppressing the permission prompt? To use "provisional permissions" on iOS 12 in order to get permission without prompting the user.

But failing to execute `::firebase::messaging::RequestPermission()` will prevent FCM to call `UIApplication
.registerForRemoteNotifications` and we will never get an APNS token. I filled it as a bug since it is unclear that APNS registration is performed only when requesting permissions and this prevents client apps to use provisional permissions while still relying on FCM for APNS registration.

#### Steps to reproduce:

Have you been able to reproduce this issue with just the [Firebase C++ quickstarts](https://github.com/firebase/quickstart-cpp) ? Yes with code change to adjust for provisional permissions

What's the issue repro rate? (eg 100%, 1/5 etc)
Always

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

1. remove call to `::firebase::messaging::RequestPermission()` in file `common_main.cc`
2. replace with your own call to request provisional user notification permission on iOS 12+
3. run app as usual, console will display:

2023-03-02 [423:10411] 10.4.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '18207577403'.Be sure to re-retrieve the FCM token once the APNS device token is set.
2023-03-02 [423:10411] 10.4.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified

#### Relevant Code:

Code the request provisional permissions:

```
UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound
| UNAuthorizationOptionBadge;
if (__builtin_available(iOS 12.0, *)) {
options |= UNAuthorizationOptionProvisional;
}
UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:options
completionHandler:^(BOOL granted, NSError * _Nullable error)
{
notify_app(granted);
}];
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.