Skip to content

Remove messaging-types-exp #4498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 24, 2021
Merged
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
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@firebase/installations-types-exp",
"@firebase/installations-compat",
"@firebase/messaging-exp",
"@firebase/messaging-types-exp",
"@firebase/performance-exp",
"@firebase/performance-types-exp",
"@firebase/remote-config-exp",
Expand Down
43 changes: 39 additions & 4 deletions common/api-review/messaging-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@
```ts

import { FirebaseApp } from '@firebase/app-exp';
import { FirebaseMessaging } from '@firebase/messaging-types-exp';
import { MessagePayload } from '@firebase/messaging-types-exp';
import { NextFn } from '@firebase/util';
import { Observer } from '@firebase/util';
import { Unsubscribe } from '@firebase/util';

// @public
export function deleteToken(messaging: FirebaseMessaging): Promise<boolean>;

export { FirebaseMessaging }
// @public (undocumented)
export interface FcmOptions {
// (undocumented)
analyticsLabel?: string;
// (undocumented)
link?: string;
}

// @public (undocumented)
export interface FirebaseMessaging {
}

// @internal (undocumented)
export type _FirebaseMessagingName = 'messaging';

// @public
export function getMessaging(app: FirebaseApp): FirebaseMessaging;
Expand All @@ -25,7 +36,31 @@ export function getToken(messaging: FirebaseMessaging, options?: {
swReg?: ServiceWorkerRegistration;
}): Promise<string>;

export { MessagePayload }
// @public (undocumented)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these have documentation? It looks like they didn't previously.

Copy link
Member Author

Choose a reason for hiding this comment

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

They should. @zwu52, can you please add missing comments for the public APIs. Let's do it in a separate PR though.

export interface MessagePayload {
// (undocumented)
collapseKey: string;
// (undocumented)
data?: {
[key: string]: string;
};
// (undocumented)
fcmOptions?: FcmOptions;
// (undocumented)
from: string;
// (undocumented)
notification?: NotificationPayload;
}

// @public
export interface NotificationPayload {
// (undocumented)
body?: string;
// (undocumented)
image?: string;
// (undocumented)
title?: string;
}

// @public
export function onMessage(messaging: FirebaseMessaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
Expand Down
1 change: 0 additions & 1 deletion packages-exp/messaging-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"dependencies": {
"@firebase/component": "0.1.21",
"@firebase/installations-exp": "0.0.900",
"@firebase/messaging-types-exp": "0.0.900",
"@firebase/util": "0.3.4",
"idb": "3.0.2",
"tslib": "^1.11.1"
Expand Down
52 changes: 27 additions & 25 deletions packages-exp/messaging-exp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
* limitations under the License.
*/

import {
FirebaseMessaging,
MessagePayload
} from '@firebase/messaging-types-exp';
import { FirebaseMessaging, MessagePayload } from './interfaces/public-types';
import { NextFn, Observer, Unsubscribe } from '@firebase/util';

import { MessagingService } from './messaging-service';
Expand All @@ -32,7 +29,9 @@ import { onMessage as _onMessage } from './api/onMessage';
/**
* Retrieves a firebase messaging instance.
*
* @return the firebase messaging instance associated with the provided firebase app.
* @returns the firebase messaging instance associated with the provided firebase app.
*
* @public
*/
export function getMessaging(app: FirebaseApp): FirebaseMessaging {
const messagingProvider: Provider<'messaging-exp'> = _getProvider(
Expand All @@ -50,25 +49,26 @@ export function getMessaging(app: FirebaseApp): FirebaseMessaging {
* If a notification permission isn't already granted, this method asks the user for permission.
* The returned promise rejects if the user does not allow the app to show notifications.
*
* @param messaging: the messaging instance.
* @param options.vapidKey The public server key provided to push services. It is used to
* @param messaging - the messaging instance.
* @param options.vapidKey - The public server key provided to push services. It is used to
* authenticate the push subscribers to receive push messages only from sending servers that
* hold the corresponding private key. If it is not provided, a default VAPID key is used. Note
* that some push services (Chrome Push Service) require a non-default VAPID key. Therefore, it
* is recommended to generate and import a VAPID key for your project with
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_with_fcm Configure Web Credentials with FCM}.
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_with_fcm | Configure Web Credentials with FCM}.
* See
* {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol The Web Push Protocol}
* for details on web push services.}
* {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol | The Web Push Protocol}
* for details on web push services.
*
* @param options.serviceWorkerRegistration The service worker registration for receiving push
* @param options.serviceWorkerRegistration - The service worker registration for receiving push
* messaging. If the registration is not provided explicitly, you need to have a
* `firebase-messaging-sw.js` at your root location. See
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#retrieve-the-current-registration-token Retrieve the current registration token}
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#retrieve-the-current-registration-token | Retrieve the current registration token}
* for more details.
*
* @return The promise resolves with an FCM registration token.
* @returns The promise resolves with an FCM registration token.
*
* @public
*/
export async function getToken(
messaging: FirebaseMessaging,
Expand All @@ -81,9 +81,11 @@ export async function getToken(
* Deletes the registration token associated with this messaging instance and unsubscribes the
* messaging instance from the push subscription.
*
* @param messaging: the messaging instance.
* @param messaging - the messaging instance.
*
* @returns The promise resolves when the token has been successfully deleted.
*
* @return The promise resolves when the token has been successfully deleted.
* @public
*/
export function deleteToken(messaging: FirebaseMessaging): Promise<boolean> {
return _deleteToken(messaging as MessagingService);
Expand All @@ -95,11 +97,12 @@ export function deleteToken(messaging: FirebaseMessaging): Promise<boolean> {
* the push message.
*
*
* @param messaging: the messaging instance.
* @param
* nextOrObserver This function, or observer object with `next` defined,
* @param messaging - the messaging instance.
* @param nextOrObserver - This function, or observer object with `next` defined,
* is called when a message is received and the user is currently viewing your page.
* @return To stop listening for messages execute this returned function.
* @returns To stop listening for messages execute this returned function.
*
* @public
*/
export function onMessage(
messaging: FirebaseMessaging,
Expand All @@ -112,18 +115,17 @@ export function onMessage(
* Called when a message is received while the app is in the background. An app is considered to
* be in the background if no active window is displayed.
*
* @param messaging: the messaging instance.
* @param
* nextOrObserver This function, or observer object with `next` defined,
* @param messaging - the messaging instance.
* @param nextOrObserver - This function, or observer object with `next` defined,
* is called when a message is received and the app is currently in the background.
*
* @return To stop listening for messages execute this returned function
* @returns To stop listening for messages execute this returned function
*
* @public
*/
export function onBackgroundMessage(
messaging: FirebaseMessaging,
nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>
): Unsubscribe {
return _onBackgroundMessage(messaging as MessagingService, nextOrObserver);
}

export { FirebaseMessaging, MessagePayload };
2 changes: 1 addition & 1 deletion packages-exp/messaging-exp/src/api/onBackgroundMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { ERROR_FACTORY, ErrorCode } from '../util/errors';
import { NextFn, Observer, Unsubscribe } from '@firebase/util';

import { MessagePayload } from '@firebase/messaging-types-exp';
import { MessagePayload } from '../interfaces/public-types';
import { MessagingService } from '../messaging-service';
import { SwController } from '../listeners/sw-controller';

Expand Down
2 changes: 1 addition & 1 deletion packages-exp/messaging-exp/src/api/onMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { ERROR_FACTORY, ErrorCode } from '../util/errors';
import { NextFn, Observer, Unsubscribe } from '@firebase/util';

import { MessagePayload } from '@firebase/messaging-types-exp';
import { MessagePayload } from '../interfaces/public-types';
import { MessagingService } from '../messaging-service';
import { messageEventListener } from '../listeners/messageEventListener';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { MessagePayload } from '@firebase/messaging-types-exp';
import { MessagePayload } from '../interfaces/public-types';
import { MessagePayloadInternal } from '../interfaces/internal-message-payload';
import { expect } from 'chai';
import { externalizePayload } from './externalizePayload';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { MessagePayload } from '@firebase/messaging-types-exp';
import { MessagePayload } from '../interfaces/public-types';
import { MessagePayloadInternal } from '../interfaces/internal-message-payload';

export function externalizePayload(
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/messaging-exp/src/index.sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { FirebaseMessaging } from '@firebase/messaging-types-exp';
import { FirebaseMessaging } from './interfaces/public-types';
import { registerMessaging } from './helpers/register';
import '@firebase/installations-exp';

Expand Down
12 changes: 3 additions & 9 deletions packages-exp/messaging-exp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@
* limitations under the License.
*/

import { FirebaseMessaging } from '@firebase/messaging-types-exp';
import { FirebaseMessaging } from './interfaces/public-types';
import { registerMessaging } from './helpers/register';
import '@firebase/installations-exp';

export {
getToken,
deleteToken,
onMessage,
getMessaging,
FirebaseMessaging,
MessagePayload
} from './api';
export { getToken, deleteToken, onMessage, getMessaging } from './api';
export * from './interfaces/public-types';

declare module '@firebase/component' {
interface NameServiceMapping {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google LLC
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/messaging-exp/src/messaging-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { NextFn, Observer } from '@firebase/util';

import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
import { FirebaseInternalDependencies } from './interfaces/internal-dependencies';
import { MessagePayload } from '@firebase/messaging-types-exp';
import { MessagePayload } from './interfaces/public-types';
import { Provider } from '@firebase/component';
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
import { extractAppConfig } from './helpers/extract-app-config';
Expand Down
3 changes: 0 additions & 3 deletions packages-exp/messaging-types-exp/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions packages-exp/messaging-types-exp/package.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages-exp/messaging-types-exp/tsconfig.json

This file was deleted.