Skip to content

Commit

Permalink
BREAKING CHANGE: forward-port to firebase-android-sdk v26 / firebase-…
Browse files Browse the repository at this point in the history
…ios-sdk v7

    This drops a large number of deprecated APIs
    - on-device MLKit model APIs are in `@react-native-mlkit` now
    - deprecated remote-config APIs are purged
    - many other changes, please refer to the upstream release notes for details:
      - https://firebase.google.com/support/release-notes/android#2020-10-27
      - https://firebase.google.com/support/release-notes/ios#version_700_-_october_26_2020

    This also changes how you statically link firebase-ios-sdk. If you have special linking needs, read:
      - https://firebase.google.com/docs/ios/link-firebase-static-dynamic
  • Loading branch information
mikehardy committed Oct 31, 2020
1 parent fcffca5 commit 0b5d852
Show file tree
Hide file tree
Showing 168 changed files with 434 additions and 6,322 deletions.
14 changes: 0 additions & 14 deletions packages/analytics/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ describe('Analytics', () => {
});
});

it('errors if milliseconds not a number', () => {
// @ts-ignore test
expect(() => firebase.analytics().setMinimumSessionDuration('123')).toThrowError(
"'milliseconds' expected a number value",
);
});

it('errors if milliseconds is less than 0', () => {
// @ts-ignore test
expect(() => firebase.analytics().setMinimumSessionDuration(-100)).toThrowError(
"'milliseconds' expected a positive number value",
);
});

it('errors if milliseconds not a number', () => {
// @ts-ignore test
expect(() => firebase.analytics().setSessionTimeoutDuration('123')).toThrowError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ Task<Void> setAnalyticsCollectionEnabled(Boolean enabled) {
});
}

Task<Void> setMinimumSessionDuration(long milliseconds) {
return Tasks.call(() -> {
FirebaseAnalytics.getInstance(getContext()).setMinimumSessionDuration(milliseconds);
return null;
});
}

Task<Void> setSessionTimeoutDuration(long milliseconds) {
return Tasks.call(() -> {
FirebaseAnalytics.getInstance(getContext()).setSessionTimeoutDuration(milliseconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public void setAnalyticsCollectionEnabled(Boolean enabled, Promise promise) {
});
}

@ReactMethod
public void setMinimumSessionDuration(double milliseconds, Promise promise) {
module.setMinimumSessionDuration((long) milliseconds).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
promise.resolve(task.getResult());
} else {
rejectPromiseWithExceptionMap(promise, task.getException());
}
});
}

@ReactMethod
public void setSessionTimeoutDuration(double milliseconds, Promise promise) {
module.setSessionTimeoutDuration((long) milliseconds).addOnCompleteListener(task -> {
Expand Down
20 changes: 0 additions & 20 deletions packages/analytics/e2e/analytics.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,6 @@ describe('analytics()', () => {
});
});

describe('setCurrentScreen()', () => {
it('screenName only', async () => {
await firebase.analytics().setCurrentScreen('invertase screen');
});

it('screenName with screenClassOverride', async () => {
await firebase.analytics().setCurrentScreen('invertase screen', 'invertase class override');
});
});

describe('setMinimumSessionDuration()', () => {
it('default duration', async () => {
await firebase.analytics().setMinimumSessionDuration();
});

it('custom duration', async () => {
await firebase.analytics().setMinimumSessionDuration(1337);
});
});

describe('setSessionTimeoutDuration()', () => {
it('default duration', async () => {
await firebase.analytics().setSessionTimeoutDuration();
Expand Down
10 changes: 0 additions & 10 deletions packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,6 @@ - (dispatch_queue_t)methodQueue {
return resolve([NSNull null]);
}

RCT_EXPORT_METHOD(setMinimumSessionDuration:
(double) milliseconds
resolver:
(RCTPromiseResolveBlock) resolve
rejecter:
(RCTPromiseRejectBlock) reject) {
// Do nothing - this only exists in android
return resolve([NSNull null]);
}

RCT_EXPORT_METHOD(setSessionTimeoutDuration:
(double) milliseconds
resolver:
Expand Down
33 changes: 0 additions & 33 deletions packages/analytics/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,39 +663,6 @@ export namespace FirebaseAnalyticsTypes {
*/
setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;

/**
* Sets the current screen name.
*
* #### Example
*
* ```js
* await firebase.analytics().setCurrentScreen('ProductScreen', 'ProductScreen');
* ```
*
* > Whilst screenClassOverride is optional, it is recommended it is
* always sent as your current class name. For example on Android it will always
* show as 'MainActivity' if you do not specify it.
*
* @param screenName A screen name, e.g. Product.
* @param screenClassOverride On Android, React Native runs in a single activity called
* 'MainActivity'. Setting this parameter overrides the default name shown on logs.
* @deprecated
*/
setCurrentScreen(screenName: string, screenClassOverride?: string): Promise<void>;
/**
* Sets the minimum engagement time required before starting a session.
*
* #### Example
*
* ```js
* // 20 seconds
* await firebase.analytics().setMinimumSessionDuration(20000);
* ```
*
* @param milliseconds The default value is 10000 (10 seconds).
*/
setMinimumSessionDuration(milliseconds?: number): Promise<void>;

/**
* Sets the duration of inactivity that terminates the current session.
*
Expand Down
30 changes: 13 additions & 17 deletions packages/analytics/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,20 @@ import version from './version';
import * as structs from './structs';

const ReservedEventNames = [
'ad_reward',
'app_background',
'app_clear_data',
'app_uninstall',
'app_exception',
'app_remove',
'app_store_refund',
'app_store_subscription_cancel',
'app_store_subscription_convert',
'app_store_subscription_renew',
'app_update',
'app_upgrade',
'dynamic_link_app_open',
'dynamic_link_app_update',
'dynamic_link_first_open',
'error',
'first_open',
'in_app_purchase',
Expand All @@ -49,6 +60,7 @@ const ReservedEventNames = [
'notification_receive',
'os_update',
'session_start',
'session_start_with_rollout',
'user_engagement',
];

Expand Down Expand Up @@ -113,22 +125,6 @@ class FirebaseAnalyticsModule extends FirebaseModule {
});
}

setMinimumSessionDuration(milliseconds = 10000) {
if (!isNumber(milliseconds)) {
throw new Error(
"firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a number value.",
);
}

if (milliseconds < 0) {
throw new Error(
"firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a positive number value.",
);
}

return this.native.setMinimumSessionDuration(milliseconds);
}

setSessionTimeoutDuration(milliseconds = 1800000) {
if (!isNumber(milliseconds)) {
throw new Error(
Expand Down
2 changes: 0 additions & 2 deletions packages/analytics/type-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ console.log(firebase.analytics().setAnalyticsCollectionEnabled);
console.log(firebase.analytics().logSelectPromotion);
console.log(firebase.analytics().logScreenView);
console.log(firebase.analytics().logViewPromotion);
console.log(firebase.analytics().setMinimumSessionDuration);
console.log(firebase.analytics().setSessionTimeoutDuration);
console.log(firebase.analytics().setUserId);
console.log(firebase.analytics().setUserProperties);
Expand Down Expand Up @@ -110,7 +109,6 @@ console.log(analytics().setAnalyticsCollectionEnabled);
console.log(analytics().logSelectPromotion);
console.log(analytics().logScreenView);
console.log(analytics().logViewPromotion);
console.log(analytics().setMinimumSessionDuration);
console.log(analytics().setSessionTimeoutDuration);
console.log(analytics().setUserId);
console.log(analytics().setUserProperties);
Expand Down
7 changes: 0 additions & 7 deletions packages/app/RNFBApp.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,4 @@ Pod::Spec.new do |s|

# Firebase dependencies
s.dependency 'Firebase/CoreOnly', 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
2 changes: 1 addition & 1 deletion packages/app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath("com.android.tools.build:gradle:4.1.0")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ public Map<String, Object> getConstants() {


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
constants.put(KEY_DOCUMENT_DIRECTORY, folder.getAbsolutePath());
constants.put(KEY_DOCUMENT_DIRECTORY, context.getExternalFilesDir(null).getAbsolutePath());
} else {
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
}
Expand Down
11 changes: 5 additions & 6 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@
},
"sdkVersions": {
"ios": {
"firebase": "~> 6.34.0"
"firebase": "~> 7.0.0"
},
"android": {
"minSdk": 16,
"targetSdk": 29,
"compileSdk": 29,
"buildTools": "29.0.3",
"firebase": "25.12.0",
"iid": "20.3.0",
"targetSdk": 30,
"compileSdk": 30,
"buildTools": "30.0.2",
"firebase": "26.0.0",
"playServicesAuth": "18.1.0"
}
}
Expand Down
16 changes: 8 additions & 8 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ - (void)invalidate {
}];
}

[[FIRAuth authWithApp:firebaseApp] signInAndRetrieveDataWithCredential:credential completion:^(
[[FIRAuth authWithApp:firebaseApp] signInWithCredential:credential completion:^(
FIRAuthDataResult *authResult,
NSError *error
) {
Expand Down Expand Up @@ -624,14 +624,14 @@ - (void)invalidate {

NSMutableDictionary *data = [NSMutableDictionary dictionary];

if ([info dataForKey:FIRActionCodeEmailKey] != nil) {
[data setValue:[info dataForKey:FIRActionCodeEmailKey] forKey:keyEmail];
if (info.email != nil) {
[data setValue:info.email forKey:keyEmail];
} else {
[data setValue:[NSNull null] forKey:keyEmail];
}

if ([info dataForKey:FIRActionCodeFromEmailKey] != nil) {
[data setValue:[info dataForKey:FIRActionCodeFromEmailKey] forKey:@"fromEmail"];
if (info.previousEmail != nil) {
[data setValue:info.previousEmail forKey:@"fromEmail"];
} else {
[data setValue:[NSNull null] forKey:@"fromEmail"];
}
Expand Down Expand Up @@ -767,7 +767,7 @@ - (void)invalidate {
FIRAuthCredential *credential =
[[FIRPhoneAuthProvider provider] credentialWithVerificationID:verificationId verificationCode:verificationCode];

[[FIRAuth authWithApp:firebaseApp] signInAndRetrieveDataWithCredential:credential completion:^(
[[FIRAuth authWithApp:firebaseApp] signInWithCredential:credential completion:^(
FIRAuthDataResult *authResult,
NSError *error
) {
Expand Down Expand Up @@ -798,7 +798,7 @@ - (void)invalidate {

FIRUser *user = [FIRAuth authWithApp:firebaseApp].currentUser;
if (user) {
[user linkAndRetrieveDataWithCredential:credential
[user linkWithCredential:credential
completion:^(FIRAuthDataResult *_Nullable authResult, NSError *_Nullable error) {
if (error) {
[self promiseRejectAuthException:reject error:error];
Expand Down Expand Up @@ -852,7 +852,7 @@ - (void)invalidate {
FIRUser *user = [FIRAuth authWithApp:firebaseApp].currentUser;

if (user) {
[user reauthenticateAndRetrieveDataWithCredential:credential completion:^(
[user reauthenticateWithCredential:credential completion:^(
FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/e2e/firestore.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ describe('firestore()', () => {
});

describe('wait for pending writes', () => {
it('waits for pending writes', async () => {
xit('waits for pending writes', async () => {
const waitForPromiseMs = 500;
const testTimeoutMs = 10000;

Expand Down
11 changes: 2 additions & 9 deletions packages/iid/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath("com.android.tools.build:gradle:4.1.0")
}
}
}
Expand All @@ -32,12 +32,6 @@ def packageJson = PackageJson.getForProject(project)
def appPackageJson = PackageJson.getForProject(appProject)
def firebaseBomVersion = appPackageJson['sdkVersions']['android']['firebase']

// TODO Must put the concrete version here as the BoM no longer publishes the IID version, align it with the BoM change above
// Upstream issue: https://github.com/firebase/firebase-android-sdk/issues/1077
// Issue: https://github.com/invertase/react-native-firebase/issues/3918
// Example of where to find concrete version to match BoM: https://firebase.google.com/support/release-notes/android#iid_v20-2-1
def firebaseIidVersion = appPackageJson['sdkVersions']['android']['iid']

def jsonMinSdk = appPackageJson['sdkVersions']['android']['minSdk']
def jsonTargetSdk = appPackageJson['sdkVersions']['android']['targetSdk']
def jsonCompileSdk = appPackageJson['sdkVersions']['android']['compileSdk']
Expand Down Expand Up @@ -65,7 +59,6 @@ project.ext {

firebase: [
bom: firebaseBomVersion,
iid: firebaseIidVersion
],

],
Expand Down Expand Up @@ -99,7 +92,7 @@ repositories {
dependencies {
api appProject
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-iid:${ReactNative.ext.getVersion("firebase", "iid")}"
implementation "com.google.firebase:firebase-iid"
}

ReactNative.shared.applyPackageVersion()
Expand Down
24 changes: 0 additions & 24 deletions packages/messaging/e2e/messaging.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,6 @@ describe('messaging()', () => {
});
});

describe('onMessageSent()', () => {
it('throws if listener is not a function', () => {
try {
firebase.messaging().onMessageSent(123);
return Promise.reject(new Error('Did not throw Error.'));
} catch (e) {
e.message.should.containEql("'listener' expected a function");
return Promise.resolve();
}
});
});

describe('onSendError()', () => {
it('throws if listener is not a function', () => {
try {
firebase.messaging().onSendError('123');
return Promise.reject(new Error('Did not throw Error.'));
} catch (e) {
e.message.should.containEql("'listener' expected a function");
return Promise.resolve();
}
});
});

describe('setBackgroundMessageHandler()', () => {
it('throws if handler is not a function', () => {
try {
Expand Down
Loading

0 comments on commit 0b5d852

Please sign in to comment.