firebase / firebase/firebase-cpp-sdk

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

オープン
#1,227 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
api: messaging type: feature request
主要言語
C++
スター
326
フォーク
137
平均マージ
3日 9時間
マージ済み PR(30日)
5

説明

### [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);
}];
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。