Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/firebase_messaging/firebase_messaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ override func application(
}
```

### Registering with a Firebase Installation ID

`register()`, `unregister()`, `onRegistered` and `onUnregistered` replace the token API.
On Android, iOS and macOS, the native SDKs turn registration by Firebase Installation ID off
by default, and `register()` and `unregister()` fail until the app enables it.
Comment on lines +49 to +50

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Using "disable ... by default" is more standard and idiomatic in technical documentation than "turn ... off by default".


Android, in `android/app/src/main/AndroidManifest.xml` inside `<application>`:

```xml
<meta-data
android:name="firebase_messaging_installation_id_enabled"
android:value="true" />
```

iOS and macOS, in `Info.plist`:

```xml
<key>FirebaseMessagingInstallationIdEnabled</key>
<true/>
```

With this setting, the token API (`getToken()`, `deleteToken()`) fails on those platforms.

## Issues and feedback

Please file FlutterFire specific issues, bugs, or feature requests in our [issue tracker](https://github.com/firebase/flutterfire/issues/new).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class FirebaseMessaging extends FirebasePlugin {
/// Removes access to an FCM token previously authorized.
///
/// Messages sent by the server to this token will fail.
///
/// On Android, iOS and macOS, this fails once registration by FID is enabled
/// for [register].
Comment on lines +165 to +166

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The phrasing "enabled for [register]" is slightly awkward because the setting is enabled globally for the application/SDK, not specifically "for" the register method. Simplifying this to "enabled" is clearer.

Suggested change
/// On Android, iOS and macOS, this fails once registration by FID is enabled
/// for [register].
/// On Android, iOS and macOS, this fails once registration by FID is enabled.

@Deprecated('Use unregister() and onUnregistered instead.')
Future<void> deleteToken() {
return _delegate.deleteToken();
Expand All @@ -181,6 +184,18 @@ class FirebaseMessaging extends FirebasePlugin {
/// Once registration completes, [onRegistered] provides the Firebase
/// Installation ID (FID) that can be used as the direct-send target for this
/// app instance.
///
/// On Android, iOS and macOS, registration by FID is turned off by default,
/// and this method fails until the app enables it:
Comment on lines +188 to +189

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Using "disabled by default" is more standard and idiomatic in API documentation than "turned off by default".

Suggested change
/// On Android, iOS and macOS, registration by FID is turned off by default,
/// and this method fails until the app enables it:
/// On Android, iOS and macOS, registration by FID is disabled by default,
/// and this method fails until the app enables it:

///
/// * Android: add
/// `<meta-data android:name="firebase_messaging_installation_id_enabled" android:value="true" />`
/// inside `<application>` in `AndroidManifest.xml`.
/// * iOS and macOS: set `FirebaseMessagingInstallationIdEnabled` to `true`
/// in `Info.plist`.
///
/// Enabling it turns off the token API on those platforms: [getToken] and
/// [deleteToken] then fail.
Future<void> register({String? vapidKey, String? serviceWorkerScriptPath}) {
return _delegate.register(
vapidKey: vapidKey,
Expand All @@ -192,6 +207,9 @@ class FirebaseMessaging extends FirebasePlugin {
///
/// Once unregistration completes, [onUnregistered] provides the Firebase
/// Installation ID (FID) that is no longer active for direct-send messaging.
///
/// Like [register], this fails on Android, iOS and macOS unless registration
/// by FID is enabled in the app; see [register] for the setting.
Future<void> unregister() {
return _delegate.unregister();
}
Expand Down Expand Up @@ -219,6 +237,9 @@ class FirebaseMessaging extends FirebasePlugin {
/// On web, a custom messaging service worker can be registered with
/// [serviceWorkerScriptPath]. This must point to a JavaScript file in the
/// root of the app's `web` directory.
///
/// On Android, iOS and macOS, this fails once registration by FID is enabled
/// for [register].
Comment on lines +241 to +242

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The phrasing "enabled for [register]" is slightly awkward because the setting is enabled globally for the application/SDK, not specifically "for" the register method. Simplifying this to "enabled" is clearer.

Suggested change
/// On Android, iOS and macOS, this fails once registration by FID is enabled
/// for [register].
/// On Android, iOS and macOS, this fails once registration by FID is enabled.

@Deprecated('Use register() and onRegistered instead.')
Future<String?> getToken({
String? vapidKey,
Expand Down
Loading