firebase / firebase/firebase-cpp-sdk
[Bug] Cannot use provisional notification permissions with FCM on iOS
- Lingua principale
- C++
- Stelle
- 326
- Fork
- 137
- Merge medio
- 3g 9h
- PR unite (30g)
- 5
Descrizione
### [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);
}];
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da common_main.cc nel Firebase C++ quickstart e riproduci il flusso delle autorizzazioni provvisorie di iOS 12+ descritto nell’issue. Traccia il modo in cui Firebase Messaging gestisce RequestPermission, la registrazione APNS e il recupero del token FCM. Il lavoro è completato quando FCM ottiene un token APNS e può recuperare un token FCM senza richiedere la richiesta di autorizzazione di Firebase.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, firebase, ios
- Ambito
- mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100