Skip to content

Commit

Permalink
feat(installations): implement Firebase Installations module
Browse files Browse the repository at this point in the history
In particular Installations.delete() is needed for GDPR compliance
  • Loading branch information
mikehardy committed Aug 18, 2021
1 parent 0f935e8 commit 3ef3410
Show file tree
Hide file tree
Showing 37 changed files with 1,521 additions and 47 deletions.
1 change: 1 addition & 0 deletions .spellcheck.dict.txt
Expand Up @@ -55,6 +55,7 @@ Fastlane
FCM
firebase
Firebase
FirebaseApp
firebase-ios-sdk
Firestore
getIdToken
Expand Down
3 changes: 2 additions & 1 deletion docs/app/usage.md
Expand Up @@ -21,13 +21,14 @@ for manually initializing secondary Firebase app instances.

Currently, the native Firebase SDKs only provide functionality for creating secondary apps on the following services:

- [AppCheck](/app-check/usage).
- [App Check](/app-check/usage).
- [Authentication](/auth/usage).
- [Realtime Database](/database/usage).
- [Cloud Firestore](/firestore/usage).
- [Cloud Functions](/functions/usage)
- [Cloud Storage](/storage/usage).
- [ML](/ml/usage).
- [Installations](/installations/usage),
- [Remote Config](/remote-config/usage).

## Initializing secondary apps
Expand Down
2 changes: 1 addition & 1 deletion docs/in-app-messaging/usage/index.md
Expand Up @@ -2,7 +2,7 @@
title: In App Messaging
description: Installation and getting started with In App Messaging.
icon: //static.invertase.io/assets/firebase/in-app-messaging.svg
next: /ml/usage
next: /installations/usage
previous: /dynamic-links/usage
---

Expand Down
37 changes: 37 additions & 0 deletions docs/installations/usage/index.md
@@ -0,0 +1,37 @@
---
title: Installations
description: Installation and getting started with Installations.
icon: //static.invertase.io/assets/social/firebase-logo.png
next: /ml/usage
previous: /in-app-messaging/usage
---

# Installation

This module requires that the `@react-native-firebase/app` module is already setup and installed. To install the "app"
module, view the [Getting Started](/) documentation.

```bash
# Install & setup the app module
yarn add @react-native-firebase/app

# Install the installations module
yarn add @react-native-firebase/installations

# If you're developing your app using iOS, run this command
cd ios/ && pod install
```

# What does it do

The Firebase installations service:

- provides a unique identifier for a Firebase installation
- provides an auth token for a Firebase installation
- provides an API to perform GDPR-compliant deletion of a Firebase installation.

Each configured `FirebaseApp` has a corresponding single instance of Installations. An instance of the class provides access to the installation info for the FirebaseApp as well as the ability to delete it. A Firebase Installation is unique by `FirebaseApp.name` and `FirebaseApp.options.googleAppID`

# Usage

Please see the API Reference for detailed usage information on the available APIs
2 changes: 1 addition & 1 deletion docs/ml/usage/index.md
Expand Up @@ -3,7 +3,7 @@ title: ML
description: Installation and getting started with ML.
icon: //static.invertase.io/assets/firebase/ml-kit.svg
next: /remote-config/usage
previous: /in-app-messaging/usage
previous: /installations/usage
---

# Installation
Expand Down
4 changes: 4 additions & 0 deletions docs/sidebar.yaml
Expand Up @@ -97,6 +97,10 @@
- - - Usage
- '/in-app-messaging/usage'
- '//static.invertase.io/assets/firebase/in-app-messaging.svg'
- - Installations
- - - Usage
- '/installations/usage'
- '//static.invertase.io/assets/social/firebase-logo.png'
- - ML
- - - Usage
- '/ml/usage'
Expand Down
1 change: 1 addition & 0 deletions packages/app/lib/internal/constants.js
Expand Up @@ -27,6 +27,7 @@ export const KNOWN_NAMESPACES = [
'crashlytics',
'database',
'inAppMessaging',
'installations',
'firestore',
'functions',
'indexing',
Expand Down
65 changes: 65 additions & 0 deletions packages/installations/.npmignore
@@ -0,0 +1,65 @@
# Built application files
android/*/build/

# Crashlytics configuations
android/com_crashlytics_export_strings.xml

# Local configuration file (sdk path, etc)
android/local.properties

# Gradle generated files
android/.gradle/

# Signing files
android/.signing/

# User-specific configurations
android/.idea/gradle.xml
android/.idea/libraries/
android/.idea/workspace.xml
android/.idea/tasks.xml
android/.idea/.name
android/.idea/compiler.xml
android/.idea/copyright/profiles_settings.xml
android/.idea/encodings.xml
android/.idea/misc.xml
android/.idea/modules.xml
android/.idea/scopes/scope_settings.xml
android/.idea/vcs.xml
android/*.iml

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
ios/Pods
ios/build
*project.xcworkspace*
*xcuserdata*

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.dbandroid/gradle
android/gradlew
android/build
android/gradlew.bat
android/gradle/

.idea
coverage
yarn.lock
e2e/
.github
.vscode
.nyc_output
android/.settings
*.coverage.json
.circleci
.eslintignore
32 changes: 32 additions & 0 deletions packages/installations/LICENSE
@@ -0,0 +1,32 @@
Apache-2.0 License
------------------

Copyright (c) 2016-present Invertase Limited <oss@invertase.io> & Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this library except in compliance with the License.

You may obtain a copy of the Apache-2.0 License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Creative Commons Attribution 3.0 License
----------------------------------------

Copyright (c) 2016-present Invertase Limited <oss@invertase.io> & Contributors

Documentation and other instructional materials provided for this project
(including on a separate documentation repository or it's documentation website) are
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.

You may obtain a copy of the Creative Commons Attribution 3.0 License at

https://creativecommons.org/licenses/by/3.0/
61 changes: 61 additions & 0 deletions packages/installations/README.md
@@ -0,0 +1,61 @@
<p align="center">
<a href="https://rnfirebase.io">
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/>
</a>
<h2 align="center">React Native Firebase - Installations</h2>
</p>

<p align="center">
<a href="https://api.rnfirebase.io/coverage/installations/detail"><img src="https://api.rnfirebase.io/coverage/installations/badge?style=flat-square" alt="Coverage"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/installations"><img src="https://img.shields.io/npm/dm/@react-native-firebase/installations.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/installations"><img src="https://img.shields.io/npm/v/@react-native-firebase/installations.svg?style=flat-square" alt="NPM version"></a>
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
<a href="https://lerna.js.org/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square" alt="Maintained with Lerna"></a>
</p>

<p align="center">
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
<a href="https://www.facebook.com/groups/rnfirebase"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
</p>

----

Entry point for Firebase installations.

The Firebase installations service:

- provides a unique identifier for a Firebase installation
- provides an auth token for a Firebase installation
- provides a API to perform GDPR-compliant deletion of a Firebase installation.


[> Learn More](https://firebase.google.com/docs/projects/manage-installations)

## Installation

Requires `@react-native-firebase/app` to be installed.

```bash
yarn add @react-native-firebase/installations
```

## Documentation

- [Guides](https://rnfirebase.io/installations/usage/)
- [Reference](https://rnfirebase.io/reference/installations)

## License

- See [LICENSE](/LICENSE)

----

<p>
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-logo-small.png">
<p align="left">
Built and maintained with 馃挍 by <a href="https://invertase.io">Invertase</a>.
</p>
</p>

----
45 changes: 45 additions & 0 deletions packages/installations/RNFBInstallations.podspec
@@ -0,0 +1,45 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
appPackage = JSON.parse(File.read(File.join('..', 'app', 'package.json')))

coreVersionDetected = appPackage['version']
coreVersionRequired = package['peerDependencies'][appPackage['name']]
firebase_sdk_version = appPackage['sdkVersions']['ios']['firebase']
if coreVersionDetected != coreVersionRequired
Pod::UI.warn "NPM package '#{package['name']}' depends on '#{appPackage['name']}' v#{coreVersionRequired} but found v#{coreVersionDetected}, this might cause build issues or runtime crashes."
end

Pod::Spec.new do |s|
s.name = "RNFBInstallations"
s.version = package["version"]
s.description = package["description"]
s.summary = <<-DESC
A well tested feature rich Firebase implementation for React Native, supporting iOS & Android.
DESC
s.homepage = "http://invertase.io/oss/react-native-firebase"
s.license = package['license']
s.authors = "Invertase Limited"
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/invertaseio'
s.ios.deployment_target = "10.0"
s.source_files = 'ios/**/*.{h,m}'

# React Native dependencies
s.dependency 'React-Core'
s.dependency 'RNFBApp'

if defined?($FirebaseSDKVersion)
Pod::UI.puts "#{s.name}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
firebase_sdk_version = $FirebaseSDKVersion
end

# Firebase dependencies
s.dependency 'Firebase/Installations', firebase_sdk_version

if defined?($RNFirebaseAsStaticFramework)
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
s.static_framework = $RNFirebaseAsStaticFramework
else
s.static_framework = false
end
end
21 changes: 21 additions & 0 deletions packages/installations/__tests__/installations.test.ts
@@ -0,0 +1,21 @@
import { firebase } from '../lib';

describe('installations()', function () {
describe('namespace', function () {
it('accessible from firebase.app()', function () {
const app = firebase.app();
expect(app.installations).toBeDefined();
expect(app.installations().app).toEqual(app);
});

it('supports multiple apps', async function () {
expect(firebase.installations().app.name).toEqual('[DEFAULT]');
expect(firebase.installations(firebase.app('secondaryFromNative')).app.name).toEqual(
'secondaryFromNative',
);
expect(firebase.app('secondaryFromNative').installations().app.name).toEqual(
'secondaryFromNative',
);
});
});
});
10 changes: 10 additions & 0 deletions packages/installations/android/.editorconfig
@@ -0,0 +1,10 @@
# editorconfig
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

0 comments on commit 3ef3410

Please sign in to comment.