@react-native-firebase/installations 18.0.0 → 18.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [18.2.0](https://github.com/invertase/react-native-firebase/compare/v18.1.0...v18.2.0) (2023-07-13)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/installations
9
+
10
+ ## [18.1.0](https://github.com/invertase/react-native-firebase/compare/v18.0.0...v18.1.0) (2023-06-22)
11
+
12
+ ### Features
13
+
14
+ - **installations:** Firebase JS SDK V9 modular API ([#7095](https://github.com/invertase/react-native-firebase/issues/7095)) ([08cb0c2](https://github.com/invertase/react-native-firebase/commit/08cb0c2a14ed1513ece59bae0598d169118521c3))
15
+
6
16
  ## [18.0.0](https://github.com/invertase/react-native-firebase/compare/v17.5.0...v18.0.0) (2023-06-05)
7
17
 
8
18
  **Note:** Version bump only for package @react-native-firebase/installations
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import { firebase } from '../lib';
3
+ import { firebase, getInstallations, onIdChange } from '../lib';
4
4
 
5
5
  describe('installations()', function () {
6
6
  describe('namespace', function () {
@@ -20,4 +20,34 @@ describe('installations()', function () {
20
20
  );
21
21
  });
22
22
  });
23
+
24
+ describe('modular', function () {
25
+ describe('getInstallations', function () {
26
+ it('returns an instance of Installations', async function () {
27
+ const installations = getInstallations();
28
+ expect(installations).toBeDefined();
29
+ expect(installations.app).toBeDefined();
30
+ });
31
+
32
+ it('supports multiple apps', async function () {
33
+ const app = firebase.app();
34
+ const secondaryApp = firebase.app('secondaryFromNative');
35
+
36
+ const installations = getInstallations();
37
+ const installationsForApp = getInstallations(secondaryApp);
38
+
39
+ expect(installations.app).toEqual(app);
40
+ expect(installationsForApp.app).toEqual(secondaryApp);
41
+ });
42
+ });
43
+
44
+ describe('onIdChange', function () {
45
+ it('throws an unsupported error', async function () {
46
+ const installations = getInstallations();
47
+ expect(() => onIdChange(installations, () => {})).toThrow(
48
+ 'onIdChange() is unsupported by the React Native Firebase SDK.',
49
+ );
50
+ });
51
+ });
52
+ });
23
53
  });
package/lib/index.d.ts CHANGED
@@ -89,7 +89,7 @@ export namespace FirebaseInstallationsTypes {
89
89
  * stable, URL-safe base64 string identifier that uniquely identifies the app instance.
90
90
  * NOTE: If the application already has an existing FirebaseInstanceID then the InstanceID identifier will be used.
91
91
  *
92
- * @return Firebase Installation ID, this is a url-safe base64 string of a 128-bit integer.
92
+ * @return Firebase Installation ID, this is an url-safe base64 string of a 128-bit integer.
93
93
  */
94
94
  getId(): Promise<string>;
95
95
 
@@ -109,7 +109,7 @@ export namespace FirebaseInstallationsTypes {
109
109
  * Deletes the Firebase Installation and all associated data from the Firebase backend.
110
110
  * This call may cause Firebase Cloud Messaging, Firebase Remote Config, Firebase Predictions,
111
111
  * or Firebase In-App Messaging to not function properly. Fetching a new installations ID should
112
- * reset all of the dependent services to a stable state again. A network connection is required
112
+ * reset all the dependent services to a stable state again. A network connection is required
113
113
  * for the method to succeed. If it fails, the existing installation data remains untouched.
114
114
  */
115
115
  delete(): Promise<void>;
@@ -117,7 +117,7 @@ export namespace FirebaseInstallationsTypes {
117
117
  /**
118
118
  * TODO implement id change listener for android.
119
119
  *
120
- * Sets a new callback that will get called when Installlation ID changes.
120
+ * Sets a new callback that will get called when Installation ID changes.
121
121
  * Returns an unsubscribe function that will remove the callback when called.
122
122
  * Only the Android SDK supports sending ID change events.
123
123
  *
@@ -139,6 +139,8 @@ export const firebase: ReactNativeFirebase.Module & {
139
139
  ): ReactNativeFirebase.FirebaseApp & { installations(): FirebaseInstallationsTypes.Module };
140
140
  };
141
141
 
142
+ export * from './modular';
143
+
142
144
  export default defaultExport;
143
145
 
144
146
  /**
@@ -147,12 +149,14 @@ export default defaultExport;
147
149
  declare module '@react-native-firebase/app' {
148
150
  namespace ReactNativeFirebase {
149
151
  import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp;
152
+
150
153
  interface Module {
151
154
  installations: FirebaseModuleWithStaticsAndApp<
152
155
  FirebaseInstallationsTypes.Module,
153
156
  FirebaseInstallationsTypes.Statics
154
157
  >;
155
158
  }
159
+
156
160
  interface FirebaseApp {
157
161
  installations(): FirebaseInstallationsTypes.Module;
158
162
  }
package/lib/index.js CHANGED
@@ -77,3 +77,5 @@ export default createModuleNamespace({
77
77
  // installations().X(...);
78
78
  // firebase.installations().X(...);
79
79
  export const firebase = getFirebaseRoot();
80
+
81
+ export * from './modular';
@@ -0,0 +1,42 @@
1
+ import { ReactNativeFirebase } from '@react-native-firebase/app';
2
+ import { FirebaseInstallationsTypes } from '../index';
3
+
4
+ /**
5
+ * Returns an instance of Installations associated with the given FirebaseApp instance.
6
+ */
7
+ export declare function getInstallations(
8
+ app?: ReactNativeFirebase.FirebaseApp,
9
+ ): FirebaseInstallationsTypes.Module;
10
+
11
+ /**
12
+ * Deletes the Firebase Installation and all associated data.
13
+ */
14
+ export declare function deleteInstallations(
15
+ installations?: FirebaseInstallationsTypes.Module,
16
+ ): Promise<void>;
17
+
18
+ /**
19
+ * Creates a Firebase Installation if there isn't one for the app and returns the Installation ID.
20
+ */
21
+ export declare function getId(installations: FirebaseInstallationsTypes.Module): Promise<string>;
22
+
23
+ /**
24
+ * Returns a Firebase Installations auth token, identifying the current Firebase Installation.
25
+ */
26
+ export declare function getToken(
27
+ installations: FirebaseInstallationsTypes.Module,
28
+ forceRefresh?: boolean,
29
+ ): Promise<string>;
30
+
31
+ declare type IdChangeCallbackFn = (installationId: string) => void;
32
+ declare type IdChangeUnsubscribeFn = () => void;
33
+
34
+ /**
35
+ * Throw an error since react-native-firebase does not support this method.
36
+ *
37
+ * Sets a new callback that will get called when Installation ID changes. Returns an unsubscribe function that will remove the callback when called.
38
+ */
39
+ export declare function onIdChange(
40
+ installations: FirebaseInstallationsTypes.Module,
41
+ callback: IdChangeCallbackFn,
42
+ ): IdChangeUnsubscribeFn;
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { firebase } from '..';
19
+
20
+ /**
21
+ * @param {import("@react-native-firebase/app").ReactNativeFirebase.FirebaseApp} app
22
+ * @returns {import("..").FirebaseInstallationsTypes.Module}
23
+ */
24
+ export function getInstallations(app) {
25
+ if (app) {
26
+ return firebase.app(app.name).installations();
27
+ }
28
+ return firebase.app().installations();
29
+ }
30
+
31
+ /**
32
+ * @param {import("..").FirebaseInstallationsTypes.Module} installations
33
+ * @returns {Promise<void>}
34
+ */
35
+ export function deleteInstallations(installations) {
36
+ return firebase.app(installations.app.name).installations().delete();
37
+ }
38
+
39
+ /**
40
+ * @param {import("..").FirebaseInstallationsTypes.Module} installations
41
+ * @returns {Promise<string>}
42
+ */
43
+ export function getId(installations) {
44
+ return firebase.app(installations.app.name).installations().getId();
45
+ }
46
+
47
+ /**
48
+ * @param {import("..").FirebaseInstallationsTypes.Module} installations
49
+ * @param {boolean | undefined} forceRefresh
50
+ * @returns {Promise<string>}
51
+ */
52
+ export function getToken(installations, forceRefresh) {
53
+ return firebase.app(installations.app.name).installations().getToken(forceRefresh);
54
+ }
55
+
56
+ /**
57
+ * @param {import("..").FirebaseInstallationsTypes.Module} installations
58
+ * @param {(string) => void} callback
59
+ * @returns {() => void}
60
+ */
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
+ export function onIdChange(installations, callback) {
63
+ throw new Error('onIdChange() is unsupported by the React Native Firebase SDK.');
64
+ }
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '18.0.0';
2
+ module.exports = '18.2.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/installations",
3
- "version": "18.0.0",
3
+ "version": "18.2.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - Installations",
6
6
  "main": "lib/index.js",
@@ -22,10 +22,10 @@
22
22
  "installations"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@react-native-firebase/app": "18.0.0"
25
+ "@react-native-firebase/app": "18.2.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "db49dfeab62fa0c52530ccf2bfdfe9e27947bdbd"
30
+ "gitHead": "4c666df92028ddc3c0010a7ac102f54b600e6644"
31
31
  }