Skip to content

Commit

Permalink
Merge branch 'main' into feat/modular-remote-config
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Feb 6, 2023
2 parents f719568 + 4e170ea commit 85ff236
Show file tree
Hide file tree
Showing 88 changed files with 4,496 additions and 2,227 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests_e2e_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
name: Xcode Compile Cache
with:
key: ${{ runner.os }}-v2 # makes a unique key w/related restore key internally
max-size: 1G
max-size: 1500M

- name: Yarn Install
uses: nick-invision/retry@v2
Expand Down Expand Up @@ -195,4 +195,4 @@ jobs:

- uses: codecov/codecov-action@v3
with:
verbose: true
verbose: true
4 changes: 4 additions & 0 deletions .spellcheck.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ config-plugin
CP-User
crashlytics
Crashlytics
CustomProvider
datastore
debugToken
DebugView
deprecations
Deprecations
Expand All @@ -67,6 +69,7 @@ firebase
Firebase
firebase-admin
firebase-ios-sdk
firebase-js-sdk
FirebaseApp
firestore
Firestore
Expand Down Expand Up @@ -129,6 +132,7 @@ performant
personalization
plist
Podfile
pre-configured
pre-fetched
pre-release
pre-rendered
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)

### ⚠ BREAKING CHANGES

- **app, ios:** You must have an APNS token before calling getToken to
get an FCM token on iOS. Previously it was not required. See documentation
for setAPNSToken if you are using getToken in testing or have disabled
FCM Swizzling, and use setAPNSToken to set a token before using getToken

### Features

- **app-check:** add custom factory/provider; supports all providers ([ee7df85](https://github.com/invertase/react-native-firebase/commit/ee7df855ec0a573df5aa2e26261adf9c292aa7d5))
- **app, ios:** adopt firebase-ios-sdk 10.4.0 ([1b8df4c](https://github.com/invertase/react-native-firebase/commit/1b8df4c8e55d474c09e301f9c7b58b6128ae6485))
- **messaging, ios:** new setAPNSToken API / getToken works on M1 Simulator ([8d75b36](https://github.com/invertase/react-native-firebase/commit/8d75b36f485af07ecfa653192ca56f761d0cc5b7))

## [16.7.0](https://github.com/invertase/react-native-firebase/compare/v16.6.0...v16.7.0) (2023-01-28)

### Features
Expand Down
6 changes: 5 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ module.exports = {
],
},
},
plugins: [['@babel/plugin-proposal-private-property-in-object', { loose: true }]],
plugins: [
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-private-methods', { loose: true }],
],
};
75 changes: 61 additions & 14 deletions docs/app-check/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ This attestation is attached to every request your app makes to your Firebase ba
This App Check module has built-in support for using the following services as attestation providers:

- DeviceCheck on iOS
- SafetyNet on Android
- App Attest on iOS
- Play Integrity on Android
- SafetyNet on Android (deprecated)
- Debug providers on both platforms

App Check currently works with the following Firebase products:

Expand All @@ -71,26 +74,64 @@ The [official Firebase App Check documentation](https://firebase.google.com/docs

Before the App Check package can be used on iOS or Android, the corresponding App must be registered in the firebase console.

For instructions on how to generate required keys and register an app for App Check with iOS Device Check and Android SafetyNet, follow **Step 1** in these firebase guides:
For instructions on how to generate required keys and register an app for the desired attestation provider, follow **Step 1** in these firebase guides:

- [Get started using App Check with DeviceCheck on Apple platforms](https://firebase.google.com/docs/app-check/ios/devicecheck-provider?hl=en&authuser=1#project-setup)
- [Get started using App Check with SafetyNet on Android](https://firebase.google.com/docs/app-check/android/safetynet-provider?hl=en&authuser=1#project-setup)
- [Get started using App Check with DeviceCheck on Apple platforms](https://firebase.google.com/docs/app-check/ios/devicecheck-provider#project-setup)
- [Get started using App Check with App Attest on Apple platforms](https://firebase.google.com/docs/app-check/ios/app-attest-provider#project-setup)
- [Get started using App Check with Play Integrity on Android](https://firebase.google.com/docs/app-check/android/play-integrity-provider#project-setup)
- [Get started using App Check with SafetyNet on Android (deprecated)](https://firebase.google.com/docs/app-check/android/safetynet-provider#project-setup)

> Additionally, You can reference the iOS private key creation and registrations steps outlined in the [Cloud Messaging iOS Setup](/messaging/usage/ios-setup#linking-apns-with-fcm-ios).
## Activate
## Initialize

On iOS if you include the App Check package, it is activated by default. The only configuration possible is the token auto refresh. When you call activate, the provider (DeviceCheck by default) stays the same but the token auto refresh setting will be changed based on the argument provided.
You must call initialize the AppCheck module prior to calling any firebase back-end services for App Check to function.

On Android, App Check is not activated until you call the activate method. The provider is not configurable here either but if your app is "debuggable", then the Debug app check provider will be installed, otherwise the SafetyNet provider will be installed.
There are several differences between the web, Apple, and Android platform SDKs produced by Firebase, which react-native-firebase smooths over to give you a common, firebase-js-sdk compatible API.

You must call activate prior to calling any firebase back-end services for App Check to function.
How do we do this? We use the standard firebase-js-sdk v9 API `initializeAppCheck`, and take advantage of its parameters which allow the use of an `AppCheckOptions` argument that itself allows a `CustomProvider`.

It is through the use of a react-native-specific `ReactNativeFirebaseAppCheckProvider` that we can offer runtime configuration capability at the javascript level, including the ability to switch providers dynamically.

So AppCheck module initialization is done in two steps in react-native-firebase - first you create and configure the custom provider, then you initialize AppCheck using that custom provider.

### Configure a Custom Provider

To configure the react-native-firebase custom provider, first obtain one, then configure it according to the providers you want to use on each platform.

```javascript
rnfbProvider = firebase.appCheck().newReactNativeFirebaseAppCheckProvider();
rnfbProvider.configure({
android: {
provider: 'playIntegrity',
},
apple: {
provider: 'appAttestWithDeviceCheckFallback',
},
web: {
provider: 'reCaptchaV3',
siteKey: 'unknown',
},
});
```

Note that the available

### Install the Custom Provider

Once you have the custom provider configured, install it in app-check using the firebase-js-sdk compatible API:

```javascript
firebase.appCheck().initializeAppCheck({ provider: rnfbProvider, isTokenAutoRefreshEnabled: true });
```

## Automatic Data Collection

App Check has an "tokenAutoRefreshEnabled" setting. This may cause App Check to attempt a remote App Check token fetch prior to user consent. In certain scenarios, like those that exist in GDPR-compliant apps running for the first time, this may be unwanted.

If unset, the "tokenAutoRefreshEnabled" setting will defer to the app's "automatic data collection" setting, which may be set in the Info.plist or AndroidManifest.xml
You may configure this setting in `firebase.json` such that your desired configuration is in place even before you the react-native javascript bundle begins executing and allows for runtime configuration.

If unset, the "tokenAutoRefreshEnabled" setting will defer to the app's "automatic data collection" setting, which may be set in `firebase.json`, or if you wish directly in the Info.plist or AndroidManifest.xml according to the Firebase native SDK documentation. Unless otherwise configured, it will default to true implying there will be automatic data collection and app check token refresh attempts.

## Using App Check tokens for non-firebase services

Expand All @@ -104,9 +145,15 @@ App Check may be used in CI environments by following the upstream documentation

In certain react-native testing scenarios it may be difficult to access the shared secret, but the react-native-firebase testing app for e2e testing does successfully fetch App Check tokens via setting an environment variable and initializing the debug provider before firebase configure in AppDelegate.m for iOS.

This method mainly consists of setting an environment variable in a way that it is visible to the Simulator as it starts up. That environment variable is automatically seen and used by the Firebase Debug provider on iOS.

In a future release, the debugToken parameter of the CustomProvider apple options should allow for more dynamic configuration, PRs to the Apple CustomProvider are welcome if you are motivated to implement this feature.

### on Android

When using a _release_ build, app-check only works when running on actual Android devices. When using a _debug_ build, you have two ways to run your application / tests with App Check support.
The react-native-firebase CustomProvider implementation allows for runtime configuration of the `debug` provider as well as a `debugToken` in the `android` CustomProvider options. This allows the easy use of a token pre-configured in the Firebase console, allowing for dynamic configuration and testing of AppCheck in CI environments or Android Emulators.

There are a variety of other ways to obtain and configure debug tokens for AppCheck testing, a few of which follow:

#### A) When testing on an actual android device (debug build)

Expand All @@ -125,16 +172,16 @@ When you want to test using an Android virtual device -or- when you prefer to (r
1. In the [Project Settings > App Check](https://console.firebase.google.com/project/_/settings/appcheck) section of the Firebase console, choose _Manage debug tokens_ from your app's overflow menu. Then, register a new debug token by clicking the _Add debug token_ button, then _Generate token_.
2. Pass the token you created in the previous step by supplying a `FIREBASE_APP_CHECK_DEBUG_TOKEN` environment variable to the process that build your react-native android app. e.g.:

$ FIREBASE_APP_CHECK_DEBUG_TOKEN="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" react-native run-android
FIREBASE_APP_CHECK_DEBUG_TOKEN="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" react-native run-android

Please note that once the android app has successfully passed the app-checks controls on the device, it will keep passing them, whether you rebuild without the secret token or not. To completely reset app-check, you must first uninstall, and then re-build / install.

#### C) When using Expo Development Client

When using expo-dev-client, the process is a little different, especially on an android emulator.

1. In the [Project Settings > App Check](https://console.firebase.google.com/project/_/settings/appcheck) section of the Firebase console, choose _Manage debug tokens_ from your app's overflow menu. Then, register a new debug token by clicking the _Add debug token_ button, then _Generate token_.
2. Pass the token you created in the previous step by supplying a `FIREBASE_APP_CHECK_DEBUG_TOKEN` environment variable in your eas.json development profile:
1. In the [Project Settings > App Check](https://console.firebase.google.com/project/_/settings/appcheck) section of the Firebase console, choose _Manage debug tokens_ from your app's overflow menu. Then, register a new debug token by clicking the _Add debug token_ button, then _Generate token_.
2. Pass the token you created in the previous step by supplying a `FIREBASE_APP_CHECK_DEBUG_TOKEN` environment variable in your eas.json development profile:

```json
{
Expand All @@ -156,4 +203,4 @@ When using expo-dev-client, the process is a little different, especially on an

3. Rebuild your development client:

$ eas build --profile development --platform android
eas build --profile development --platform android
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Open your projects `/ios/Podfile` and add any of the globals shown below to the

```ruby
# Override Firebase SDK Version
$FirebaseSDKVersion = '10.3.0'
$FirebaseSDKVersion = '10.4.0'
```

Once changed, reinstall your projects pods via pod install and rebuild your project with `npx react-native run-ios`.
Expand Down
14 changes: 8 additions & 6 deletions docs/messaging/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ async function requestUserPermission() {
The permissions API for iOS provides much more fine-grain control over permissions and how they're handled within your
application. To learn more, view the advanced [iOS Permissions](/messaging/ios-permissions) documentation.

On Android, you do not need to request user permission. This method can still be called on Android devices; however, and will always resolve successfully.
On Android API level 32 and below, you do not need to request user permission. This method can still be called on Android devices; however, and will always resolve successfully. For API level 33+ you will need to request the permission manually using either the built-in react-native `PermissionsAndroid` APIs or a related module such as `react-native-permissions`

```
import {PermissionsAndroid} from 'react-native'}
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
```

## Receiving messages

Expand Down Expand Up @@ -291,12 +296,9 @@ To inject a `isHeadless` prop into your app, please update your `AppDelegate.m`
// Use `addCustomPropsToUserProps` to pass in props for initialization of your app
// Or pass in `nil` if you have none as per below example
// For `withLaunchOptions` please pass in `launchOptions` object
NSDictionary *appProperties = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
// and use it to set `self.initialProps` (available with react-native >= 0.71.1, older versions need a more difficult style, upgrading is recommended)

// Find the `RCTRootView` instance and update the `initialProperties` with your `appProperties` instance
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"nameOfYourApp"
initialProperties:appProperties];
self.initialProps = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
```
- For projects that use react-native-navigation (or if you just don't want to mess with your launchProperties) you can use the `getIsHeadless` method (iOS only) from messaging like so:
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@
"userUrlFormat": "{{host}}/{{user}}"
},
"ignoreChanges": ["**/docs/**", "**/.github/**", "**/e2e/**", "**/tests/**"],
"version": "16.7.0"
"version": "17.0.0"
}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"tests:emulator:start": "yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh --no-daemon",
"tests:emulator:start:windows": "yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.bat --no-daemon",
"tests:emulator:start-ci": "yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh",
"tests:android:build": "cd tests && cross-env FIREBASE_APP_CHECK_DEBUG_TOKEN=\"698956B2-187B-49C6-9E25-C3F3530EEBAF\" yarn detox build --configuration android.emu.debug",
"tests:android:build:windows": "cd tests && cross-env FIREBASE_APP_CHECK_DEBUG_TOKEN=\"698956B2-187B-49C6-9E25-C3F3530EEBAF\" yarn detox build --configuration android.emu.debug.windows",
"tests:android:build": "cd tests && yarn detox build --configuration android.emu.debug",
"tests:android:build:windows": "cd tests && yarn detox build --configuration android.emu.debug.windows",
"tests:android:build-release": "cd tests && yarn detox build --configuration android.emu.release",
"tests:android:test": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug",
"tests:android:test:debug": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --inspect",
Expand Down Expand Up @@ -102,13 +102,17 @@
"react-native-codegen",
"**/react-native-codegen",
"**/react-native-codegen/**",
"**/react-native-device-info",
"**/react-native-device-info/**",
"**/react-native-port-patcher/**",
"**/@react-native-firebase/private-tests-helpers",
"**/@react-native-firebase/private-tests-helpers/**",
"**/babel-plugin-istanbul",
"**/babel-plugin-istanbul/**",
"**/patch-package",
"**/patch-package/**",
"**/pretty-format",
"**/pretty-format/**",
"**/jet",
"**/jet/**",
"**/nyc",
Expand All @@ -117,6 +121,8 @@
"**/react/**",
"**/react-native",
"**/react-native/**",
"**/metro-runtime",
"**/metro-runtime/**",
"**/stacktrace-js",
"**/stacktrace-js/**",
"**/superstruct",
Expand Down
4 changes: 4 additions & 0 deletions packages/analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)

**Note:** Version bump only for package @react-native-firebase/analytics

## [16.7.0](https://github.com/invertase/react-native-firebase/compare/v16.6.0...v16.7.0) (2023-01-28)

**Note:** Version bump only for package @react-native-firebase/analytics
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/analytics",
"version": "16.7.0",
"version": "17.0.0",
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
"description": "React Native Firebase - The analytics module provides out of the box support with Google Analytics for Firebase. Integration with the Android & iOS allows for in-depth analytical insight reporting, such as device information, location, user actions and more.",
"main": "lib/index.js",
Expand All @@ -22,7 +22,7 @@
"analytics"
],
"peerDependencies": {
"@react-native-firebase/app": "16.7.0"
"@react-native-firebase/app": "17.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 6 additions & 0 deletions packages/app-check/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)

### Features

- **app-check:** add custom factory/provider; supports all providers ([ee7df85](https://github.com/invertase/react-native-firebase/commit/ee7df855ec0a573df5aa2e26261adf9c292aa7d5))

## [16.7.0](https://github.com/invertase/react-native-firebase/compare/v16.6.0...v16.7.0) (2023-01-28)

**Note:** Version bump only for package @react-native-firebase/app-check
Expand Down
1 change: 1 addition & 0 deletions packages/app-check/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ repositories {
dependencies {
api appProject
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion('firebase', 'bom')}")
implementation 'com.google.firebase:firebase-appcheck-playintegrity'
implementation "com.google.firebase:firebase-appcheck-safetynet"
implementation "com.google.firebase:firebase-appcheck-debug"
}
Expand Down
Loading

0 comments on commit 85ff236

Please sign in to comment.