diff --git a/.npmignore b/.npmignore index 0890a2e7..d2e4626d 100644 --- a/.npmignore +++ b/.npmignore @@ -75,9 +75,15 @@ coverage yarn.lock tests bridge/ -lib/.watchmanconfig buddybuild_postclone.sh bin/test.js .github example codorials +.vscode +.nyc_output +React-Native-Firebase.svg +CONTRIBUTING.md +CODE_OF_CONDUCT.md +android/.settings +README.md diff --git a/android/build.gradle b/android/build.gradle index 4c267196..acb6ecc1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -36,6 +36,9 @@ android { } productFlavors { } + lintOptions { + disable 'GradleCompatible' + } } rootProject.gradle.buildFinished { buildResult -> @@ -68,7 +71,8 @@ rootProject.gradle.buildFinished { buildResult -> logger.log(LogLevel.ERROR, "| |") logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ") } - } catch (Exception exception) {} + } catch (Exception exception) { + } } } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 6ed6b311..152971db 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -2,4 +2,6 @@ package="io.invertase.firebase"> + + diff --git a/android/src/main/java/io/invertase/firebase/links/RNFirebaseLinks.java b/android/src/main/java/io/invertase/firebase/links/RNFirebaseLinks.java index 9c308168..099bd3d3 100644 --- a/android/src/main/java/io/invertase/firebase/links/RNFirebaseLinks.java +++ b/android/src/main/java/io/invertase/firebase/links/RNFirebaseLinks.java @@ -174,7 +174,11 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ // Looks at the internals of the link data to detect whether it's an invitation or not private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) { - return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null; + FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData); + if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) { + return true; + } + return false; } private DynamicLink.Builder getDynamicLinkBuilder(final ReadableMap linkData) { diff --git a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java index 948ba9bd..185dc4d5 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java +++ b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; import java.util.Map; @@ -357,6 +358,21 @@ public class RNFirebaseNotificationManager { notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (schedule.containsKey("repeatInterval")) { + // If fireDate you specify is in the past, the alarm triggers immediately. + // So we need to adjust the time for correct operation. + if (fireDate < System.currentTimeMillis()) { + Calendar newFireDate = Calendar.getInstance(); + Calendar currentFireDate = Calendar.getInstance(); + currentFireDate.setTimeInMillis(fireDate); + + newFireDate.add(Calendar.DATE, 1); + newFireDate.set(Calendar.HOUR_OF_DAY, currentFireDate.get(Calendar.HOUR_OF_DAY)); + newFireDate.set(Calendar.MINUTE, currentFireDate.get(Calendar.MINUTE)); + newFireDate.set(Calendar.SECOND, currentFireDate.get(Calendar.SECOND)); + + fireDate = newFireDate.getTimeInMillis(); + } + Long interval = null; switch (schedule.getString("repeatInterval")) { case "minute": diff --git a/bridge/android/app/src/main/AndroidManifest.xml b/bridge/android/app/src/main/AndroidManifest.xml index b016f89e..61b4e13e 100755 --- a/bridge/android/app/src/main/AndroidManifest.xml +++ b/bridge/android/app/src/main/AndroidManifest.xml @@ -65,18 +65,45 @@ - + + android:scheme="http" + android:host="je786.app.goo.gl" /> + + + + + + + + android:scheme="http" + android:host="je786.app.goo.gl" /> + + + + + + + + + + + + + + + + diff --git a/bridge/android/app/src/main/java/com/testing/MainActivity.java b/bridge/android/app/src/main/java/com/testing/MainActivity.java index 286ab301..b0329405 100755 --- a/bridge/android/app/src/main/java/com/testing/MainActivity.java +++ b/bridge/android/app/src/main/java/com/testing/MainActivity.java @@ -32,6 +32,10 @@ public class MainActivity extends ReactActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); checkWindowPerms(); + // ATTENTION: This was auto-generated to handle app links. + Intent appLinkIntent = getIntent(); + String appLinkAction = appLinkIntent.getAction(); + Uri appLinkData = appLinkIntent.getData(); } public void checkWindowPerms() { diff --git a/bridge/e2e/iid/iid.e2e.js b/bridge/e2e/iid/iid.e2e.js index 1c249e5a..18f3a07f 100644 --- a/bridge/e2e/iid/iid.e2e.js +++ b/bridge/e2e/iid/iid.e2e.js @@ -10,13 +10,56 @@ describe('iid()', () => { it('deletes the current instance id', async () => { const iidBefore = await firebase.iid().get(); iidBefore.should.be.a.String(); - await firebase.iid().delete(); const iidAfter = await firebase.iid().get(); iidAfter.should.be.a.String(); - iidBefore.should.not.equal(iidAfter); }); }); + + describe('getToken()', () => { + it('should return an FCM token from getToken with arguments', async () => { + const authorizedEntity = firebase.iid().app.options.messagingSenderId; + + await firebase.iid().delete(); + const token = await firebase.iid().getToken(authorizedEntity, '*'); + token.should.be.a.String(); + }); + + it('should return an FCM token from getToken without arguments', async () => { + await firebase.iid().delete(); + const token = await firebase.iid().getToken(); + token.should.be.a.String(); + }); + + it('should return an FCM token from getToken with 1 argument', async () => { + const authorizedEntity = firebase.iid().app.options.messagingSenderId; + + await firebase.iid().delete(); + const token = await firebase.iid().getToken(authorizedEntity); + token.should.be.a.String(); + }); + }); + + describe('deleteToken()', () => { + it('should return nil from deleteToken with arguments', async () => { + const authorizedEntity = firebase.iid().app.options.messagingSenderId; + + const token = await firebase.iid().deleteToken(authorizedEntity, '*'); + should.not.exist(token); + }); + + it('should return nil from deleteToken without arguments', async () => { + const token = await firebase.iid().deleteToken(); + should.not.exist(token); + }); + + it('should return nil from deleteToken with 1 argument', async () => { + const authorizedEntity = firebase.iid().app.options.messagingSenderId; + + const token = await firebase.iid().deleteToken(authorizedEntity); + should.not.exist(token); + }); + }); }); diff --git a/bridge/e2e/storage/storage.e2e.js b/bridge/e2e/storage/storage.e2e.js index f5211185..50f28f5b 100644 --- a/bridge/e2e/storage/storage.e2e.js +++ b/bridge/e2e/storage/storage.e2e.js @@ -49,6 +49,18 @@ describe('storage()', () => { .downloadFile( `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/ok.jpeg` ); + await firebase + .storage() + .ref('/cat.gif') + .downloadFile( + `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/cat.gif` + ); + await firebase + .storage() + .ref('/hei.heic') + .downloadFile( + `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/hei.heic` + ); }); it('errors if permission denied', async () => { @@ -75,6 +87,20 @@ describe('storage()', () => { `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/ok.jpeg` ); + await firebase + .storage() + .ref('/uploadCat.gif') + .putFile( + `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/cat.gif` + ); + + await firebase + .storage() + .ref('/uploadHei.heic') + .putFile( + `${firebase.storage.Native.DOCUMENT_DIRECTORY_PATH}/hei.heic` + ); + uploadTaskSnapshot.state.should.eql(firebase.storage.TaskState.SUCCESS); uploadTaskSnapshot.bytesTransferred.should.eql( uploadTaskSnapshot.totalBytes diff --git a/bridge/ios/Podfile b/bridge/ios/Podfile index e54784fd..5bd2f566 100644 --- a/bridge/ios/Podfile +++ b/bridge/ios/Podfile @@ -18,21 +18,21 @@ target 'testing' do 'RCTWebSocket', ] - pod 'Firebase/AdMob' - pod 'Firebase/Auth' - pod 'Firebase/Core' - pod 'Firebase/Crash' - pod 'Firebase/Database' - pod 'Firebase/Functions' - pod 'Firebase/DynamicLinks' - pod 'Firebase/Firestore' - pod 'Firebase/Invites' - pod 'Firebase/Messaging' - pod 'Firebase/RemoteConfig' - pod 'Firebase/Storage' - pod 'Firebase/Performance' + pod 'Firebase/AdMob', '~> 5.3.0' + pod 'Firebase/Auth', '~> 5.3.0' + pod 'Firebase/Core', '~> 5.3.0' + pod 'Firebase/Crash', '~> 5.3.0' + pod 'Firebase/Database', '~> 5.3.0' + pod 'Firebase/Functions', '~> 5.3.0' + pod 'Firebase/DynamicLinks', '~> 5.3.0' + pod 'Firebase/Firestore', '~> 5.3.0' + pod 'Firebase/Invites', '~> 5.3.0' + pod 'Firebase/Messaging', '~> 5.3.0' + pod 'Firebase/RemoteConfig', '~> 5.3.0' + pod 'Firebase/Storage', '~> 5.3.0' + pod 'Firebase/Performance', '~> 5.3.0' pod 'Fabric', '~> 1.7.5' - pod 'Crashlytics', '~> 3.10.1' + pod 'Crashlytics', '~> 3.10.4' pod 'RNFirebase', :path => '../../ios/RNFirebase.podspec' diff --git a/bridge/ios/Podfile.lock b/bridge/ios/Podfile.lock index da0abb4e..4e947e5f 100644 --- a/bridge/ios/Podfile.lock +++ b/bridge/ios/Podfile.lock @@ -5,9 +5,9 @@ PODS: - BoringSSL/Implementation (10.0.5): - BoringSSL/Interface (= 10.0.5) - BoringSSL/Interface (10.0.5) - - Crashlytics (3.10.2): - - Fabric (~> 1.7.7) - - Fabric (1.7.7) + - Crashlytics (3.10.4): + - Fabric (~> 1.7.9) + - Fabric (1.7.9) - Firebase/AdMob (5.3.0): - Firebase/Core - Google-Mobile-Ads-SDK (= 7.31.0) @@ -162,25 +162,27 @@ PODS: - GoogleToolboxForMac/Defines (= 2.1.4) - "GoogleToolboxForMac/NSDictionary+URLArguments (= 2.1.4)" - "GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)" - - gRPC (1.12.0): - - gRPC-RxLibrary (= 1.12.0) - - gRPC/Main (= 1.12.0) - - gRPC-Core (1.12.0): - - gRPC-Core/Implementation (= 1.12.0) - - gRPC-Core/Interface (= 1.12.0) - - gRPC-Core/Implementation (1.12.0): + - gRPC (1.13.0): + - gRPC-RxLibrary (= 1.13.0) + - gRPC/Main (= 1.13.0) + - gRPC-Core (1.13.0): + - gRPC-Core/Implementation (= 1.13.0) + - gRPC-Core/Interface (= 1.13.0) + - gRPC-Core/Implementation (1.13.0): - BoringSSL (~> 10.0) - - gRPC-Core/Interface (= 1.12.0) + - gRPC-Core/Interface (= 1.13.0) - nanopb (~> 0.3) - - gRPC-Core/Interface (1.12.0) - - gRPC-ProtoRPC (1.12.0): - - gRPC (= 1.12.0) - - gRPC-RxLibrary (= 1.12.0) + - gRPC-Core/Interface (1.13.0) + - gRPC-ProtoRPC (1.13.0): + - gRPC-ProtoRPC/Main (= 1.13.0) + - gRPC-ProtoRPC/Main (1.13.0): + - gRPC (= 1.13.0) + - gRPC-RxLibrary (= 1.13.0) - Protobuf (~> 3.0) - - gRPC-RxLibrary (1.12.0) - - gRPC/Main (1.12.0): - - gRPC-Core (= 1.12.0) - - gRPC-RxLibrary (= 1.12.0) + - gRPC-RxLibrary (1.13.0) + - gRPC/Main (1.13.0): + - gRPC-Core (= 1.13.0) + - gRPC-RxLibrary (= 1.13.0) - GTMOAuth2 (1.1.6): - GTMSessionFetcher (~> 1.1) - GTMSessionFetcher (1.1.15): @@ -216,21 +218,21 @@ PODS: - yoga (0.55.3.React) DEPENDENCIES: - - Crashlytics (~> 3.10.1) + - Crashlytics (~> 3.10.4) - Fabric (~> 1.7.5) - - Firebase/AdMob - - Firebase/Auth - - Firebase/Core - - Firebase/Crash - - Firebase/Database - - Firebase/DynamicLinks - - Firebase/Firestore - - Firebase/Functions - - Firebase/Invites - - Firebase/Messaging - - Firebase/Performance - - Firebase/RemoteConfig - - Firebase/Storage + - Firebase/AdMob (~> 5.3.0) + - Firebase/Auth (~> 5.3.0) + - Firebase/Core (~> 5.3.0) + - Firebase/Crash (~> 5.3.0) + - Firebase/Database (~> 5.3.0) + - Firebase/DynamicLinks (~> 5.3.0) + - Firebase/Firestore (~> 5.3.0) + - Firebase/Functions (~> 5.3.0) + - Firebase/Invites (~> 5.3.0) + - Firebase/Messaging (~> 5.3.0) + - Firebase/Performance (~> 5.3.0) + - Firebase/RemoteConfig (~> 5.3.0) + - Firebase/Storage (~> 5.3.0) - React/Core (from `../node_modules/react-native`) - React/RCTNetwork (from `../node_modules/react-native`) - React/RCTText (from `../node_modules/react-native`) @@ -284,8 +286,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: BoringSSL: cf3f1793eb6e3c445c4d150456341f149c268a35 - Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d - Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095 + Crashlytics: 915a7787b84f635fb2a81f92a90e265c2c413f76 + Fabric: a2917d3895e4c1569b9c3170de7320ea1b1e6661 Firebase: 68afeeb05461db02d7c9e3215cda28068670f4aa FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2 @@ -307,10 +309,10 @@ SPEC CHECKSUMS: GoogleAPIClientForREST: f7951c455df271bc6259b3ddb4073d0026475ccf GoogleSignIn: d9ef55b10f0aa401a5de2747f59b725e4b9732ac GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f - gRPC: 9362451032695e2dfb7bafcd3740e3a27939e4ff - gRPC-Core: 9696b220565b283e021cf2722d473a4a74b7622a - gRPC-ProtoRPC: a1bd56fb1991a8dae4581250d7259eddabb66779 - gRPC-RxLibrary: 1ed5314e8b38cd6e55c9bfa048387136ae925ce9 + gRPC: 81b990caa01d7c32605d300c2ffd1b5ba0ef9e49 + gRPC-Core: a56b086a8ef5ced6f6ba5be5bc0a63fca185015a + gRPC-ProtoRPC: 842797fbe05dfcf891afb4a5048e5ccf5f06ef86 + gRPC-RxLibrary: fa6852f98d6ec0b73c0ec2f6406c26943099d501 GTMOAuth2: c77fe325e4acd453837e72d91e3b5f13116857b2 GTMSessionFetcher: 5fa5b80fd20e439ef5f545fb2cb3ca6c6714caa2 leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5 @@ -320,6 +322,6 @@ SPEC CHECKSUMS: RNFirebase: 2b25fd2e60269f26bb0a76c71dcc942b35a77df0 yoga: a23273df0088bf7f2bb7e5d7b00044ea57a2a54a -PODFILE CHECKSUM: 582ceaad051470812ad9203e13b5ea8ad20c78ac +PODFILE CHECKSUM: af3286375d5c28aa5d912b64dee23c8f7c4f9282 COCOAPODS: 1.5.3 diff --git a/bridge/package.json b/bridge/package.json index 1b75558f..f81df1e8 100755 --- a/bridge/package.json +++ b/bridge/package.json @@ -13,7 +13,7 @@ "test-android-reuse": "detox test --configuration android.emu.debug --reuse", "test-android-cover": "nyc detox test --configuration android.emu.debug", "test-android-cover-reuse": "nyc detox test --configuration android.emu.debug --reuse", - "test-ios": "detox test --configuration ios.sim.debug", + "test-ios": "detox test --configuration ios.sim.debug --loglevel warn", "test-ios-reuse": "detox test --configuration ios.sim.debug --reuse --loglevel warn", "test-ios-cover": "nyc detox test --configuration ios.sim.debug", "test-ios-cover-reuse": "nyc detox test --configuration ios.sim.debug --reuse --loglevel warn", diff --git a/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.h b/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.h index c529237a..b7ddcda1 100644 --- a/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.h +++ b/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.h @@ -2,7 +2,7 @@ #define RNFirebaseCrashlytics_h #import -#if __has_include() +#if __has_include() #import @interface RNFirebaseCrashlytics : NSObject { diff --git a/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.m b/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.m index 393f77a1..526c9c0f 100644 --- a/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.m +++ b/ios/RNFirebase/fabric/crashlytics/RNFirebaseCrashlytics.m @@ -1,7 +1,7 @@ #import "RNFirebaseCrashlytics.h" -#if __has_include() -#import +#if __has_include() +#import @implementation RNFirebaseCrashlytics RCT_EXPORT_MODULE(); diff --git a/ios/RNFirebase/instanceid/RNFirebaseInstanceId.m b/ios/RNFirebase/instanceid/RNFirebaseInstanceId.m index 2720036b..80d79a6e 100644 --- a/ios/RNFirebase/instanceid/RNFirebaseInstanceId.m +++ b/ios/RNFirebase/instanceid/RNFirebaseInstanceId.m @@ -1,7 +1,7 @@ #import "RNFirebaseInstanceId.h" #if __has_include() -#import +//#import #import @implementation RNFirebaseInstanceId @@ -32,9 +32,9 @@ RCT_EXPORT_METHOD(getToken:(NSString *)authorizedEntity resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSDictionary * options = nil; - if ([FIRMessaging messaging].APNSToken) { - options = @{@"apns_token": [FIRMessaging messaging].APNSToken}; - } +// if ([FIRMessaging messaging].APNSToken) { +// options = @{@"apns_token": [FIRMessaging messaging].APNSToken}; +// } [[FIRInstanceID instanceID] tokenWithAuthorizedEntity:authorizedEntity scope:scope options:options handler:^(NSString * _Nullable identity, NSError * _Nullable error) { if (error) { reject(@"instance_id_error", @"Failed to getToken", error); diff --git a/ios/RNFirebase/links/RNFirebaseLinks.m b/ios/RNFirebase/links/RNFirebaseLinks.m index db3a94ea..61ef8aab 100644 --- a/ios/RNFirebase/links/RNFirebaseLinks.m +++ b/ios/RNFirebase/links/RNFirebaseLinks.m @@ -60,11 +60,11 @@ continueUserActivity:(NSUserActivity *)userActivity return [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) { - if (error != nil){ - NSLog(@"Failed to handle universal link: %@", [error localizedDescription]); - } else { - NSURL* url = dynamicLink ? dynamicLink.url : userActivity.webpageURL; + if (dynamicLink && dynamicLink.url && error == nil) { + NSURL* url = dynamicLink.url; [self sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString]; + } else { + NSLog(@"Failed to handle universal link: %@", userActivity.webpageURL); } }]; } diff --git a/ios/RNFirebase/storage/RNFirebaseStorage.m b/ios/RNFirebase/storage/RNFirebaseStorage.m index fac5986b..7d879724 100644 --- a/ios/RNFirebase/storage/RNFirebaseStorage.m +++ b/ios/RNFirebase/storage/RNFirebaseStorage.m @@ -231,11 +231,15 @@ RCT_EXPORT_METHOD(putFile:(NSString *) appDisplayName options.networkAccessAllowed = true; [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { if (info[PHImageErrorKey] == nil) { - if (UTTypeConformsTo((__bridge CFStringRef)dataUTI, kUTTypeJPEG)) { + if ( + UTTypeConformsTo((__bridge CFStringRef) dataUTI, kUTTypeJPEG) || + UTTypeConformsTo((__bridge CFStringRef) dataUTI, kUTTypePNG) || + UTTypeConformsTo((__bridge CFStringRef) dataUTI, kUTTypeGIF) + ) { firmetadata.contentType = [self utiToMimeType:dataUTI]; [self uploadData:appDisplayName data:imageData firmetadata:firmetadata path:path resolver:resolve rejecter:reject]; } else { - // if the image UTI is not JPEG then convert to JPEG, e.g. HEI + // all other image types are converted to JPEG, e.g. HEI CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); NSDictionary *imageInfo = (__bridge NSDictionary*)CGImageSourceCopyPropertiesAtIndex(source, 0, NULL); NSDictionary *imageMetadata = [imageInfo copy]; diff --git a/lib/index.d.ts b/lib/index.d.ts index b9eb37e0..c128d3e1 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1089,8 +1089,8 @@ declare module 'react-native-firebase' { interface InstanceId { delete(): Promise; get(): Promise; - getToken(authorizedEntity: string, scope: string): Promise; - deleteToken(authorizedEntity: string, scope: string): Promise; + getToken(authorizedEntity?: string, scope?: string): Promise; + deleteToken(authorizedEntity?: string, scope?: string): Promise; } } diff --git a/lib/modules/auth/phone/PhoneAuthListener.js b/lib/modules/auth/phone/PhoneAuthListener.js index 36a8a2ac..982a2e10 100644 --- a/lib/modules/auth/phone/PhoneAuthListener.js +++ b/lib/modules/auth/phone/PhoneAuthListener.js @@ -32,6 +32,7 @@ export default class PhoneAuthListener { _timeout: number; _publicEvents: Object; _internalEvents: Object; + _forceResending: boolean; _reject: Function | null; _resolve: Function | null; _credential: Object | null; diff --git a/lib/modules/database/Reference.js b/lib/modules/database/Reference.js index 72171865..1811a23f 100644 --- a/lib/modules/database/Reference.js +++ b/lib/modules/database/Reference.js @@ -299,15 +299,15 @@ export default class Reference extends ReferenceBase { * @param onComplete * @returns {*} */ - push(value: any, onComplete?: Function): ThenableReference { + push(value: any, onComplete?: Function): Reference | Promise { if (value === null || value === undefined) { - return new ThenableReference( + return new Reference( this._database, `${this.path}/${generatePushID(this._database._serverTimeOffset)}` ); } - const newRef = new ThenableReference( + const newRef = new Reference( this._database, `${this.path}/${generatePushID(this._database._serverTimeOffset)}` ); @@ -894,10 +894,10 @@ export default class Reference extends ReferenceBase { } // eslint-disable-next-line no-unused-vars -declare class ThenableReference<+R> extends Reference { - then( - onFulfill?: (value: R) => Promise | U, - onReject?: (error: any) => Promise | U - ): Promise; - catch(onReject?: (error: any) => Promise | U): Promise; -} +// class ThenableReference<+R> extends Reference { +// then( +// onFulfill?: (value: R) => Promise | U, +// onReject?: (error: any) => Promise | U +// ): Promise; +// catch(onReject?: (error: any) => Promise | U): Promise; +// } diff --git a/lib/modules/firestore/Query.js b/lib/modules/firestore/Query.js index 45827019..56164fa0 100644 --- a/lib/modules/firestore/Query.js +++ b/lib/modules/firestore/Query.js @@ -13,7 +13,12 @@ import { getNativeModule } from '../../utils/native'; import type Firestore from './'; import type Path from './Path'; -import type { MetadataChanges, QueryDirection, QueryOperator } from './types'; +import type { + MetadataChanges, + QueryDirection, + QueryOperator, + GetOptions, +} from './types'; const DIRECTIONS: { [QueryDirection]: string } = { ASC: 'ASCENDING', diff --git a/lib/modules/firestore/types.js b/lib/modules/firestore/types.js index 6ca120d0..fa97342b 100644 --- a/lib/modules/firestore/types.js +++ b/lib/modules/firestore/types.js @@ -27,7 +27,7 @@ export type NativeDocumentChange = { document: NativeDocumentSnapshot, newIndex: number, oldIndex: number, - type: string, + type: 'added' | 'modified' | 'removed', }; export type NativeDocumentSnapshot = { diff --git a/lib/modules/iid/index.js b/lib/modules/iid/index.js index 4ede6748..773fb033 100644 --- a/lib/modules/iid/index.js +++ b/lib/modules/iid/index.js @@ -7,8 +7,8 @@ import { getNativeModule } from '../../utils/native'; import type App from '../core/app'; -export const MODULE_NAME = 'RNFirebaseInstanceId'; export const NAMESPACE = 'iid'; +export const MODULE_NAME = 'RNFirebaseInstanceId'; export default class InstanceId extends ModuleBase { constructor(app: App) { @@ -20,20 +20,51 @@ export default class InstanceId extends ModuleBase { }); } - delete(): Promise { - return getNativeModule(this).delete(); - } - + /** + * Get the current Instance ID. + * + * @returns {*} + */ get(): Promise { return getNativeModule(this).get(); } - getToken(authorizedEntity: string, scope: string): Promise { - return getNativeModule(this).getToken(authorizedEntity, scope); + /** + * Delete the current Instance ID. + * + * @returns {*} + */ + delete(): Promise { + return getNativeModule(this).delete(); } - deleteToken(authorizedEntity: string, scope: string): Promise { - return getNativeModule(this).deleteToken(authorizedEntity, scope); + /** + * Get a token that authorizes an Entity to perform an action on behalf + * of the application identified by Instance ID. + * + * @param authorizedEntity + * @param scope + * @returns {Promise} + */ + getToken(authorizedEntity?: string, scope?: string): Promise { + return getNativeModule(this).getToken( + authorizedEntity || this.app.options.messagingSenderId, + scope || '*' + ); + } + + /** + * Revokes access to a scope (action) for an entity previously authorized by getToken(). + * + * @param authorizedEntity + * @param scope + * @returns {Promise} + */ + deleteToken(authorizedEntity?: string, scope?: string): Promise { + return getNativeModule(this).deleteToken( + authorizedEntity || this.app.options.messagingSenderId, + scope || '*' + ); } } diff --git a/lib/utils/index.js b/lib/utils/index.js index 6d51b6b9..ab7361ab 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -196,7 +196,7 @@ export function noop(): void {} * @returns {*} */ export function stripTrailingSlash(str: string): string { - if (!str || !isString(str)) return str; + if (!isString(str)) return str; return str.endsWith('/') ? str.slice(0, -1) : str; } diff --git a/package-lock.json b/package-lock.json index 4282e0ca..ec1b6a13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-native-firebase", - "version": "4.2.0", + "version": "4.3.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6d099010..dd0aa9bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-firebase", - "version": "4.2.0", + "version": "4.3.7", "author": "Invertase (http://invertase.io)", "description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Storage and more.", "main": "dist/index.js", @@ -35,7 +35,7 @@ "setupFiles": [], "unmockedModulePathPatterns": ["./node_modules/react", "./node_modules/react-native", "./node_modules/react-native-mock", "./node_modules/react-addons-test-utils"] }, - "license": "APACHE-2.0", + "license": "Apache-2.0", "keywords": ["react", "admob", "auth", "config", "digits", "fabric", "functions", "phone-auth", "sms", "firestore", "cloud-firestore", "datastore", "remote-config", "transactions", "react-native", "react-native-firebase", "firebase", "fcm", "apn", "gcm", "analytics", "messaging", "database", "android", "ios", "crash", "firestack", "performance", "firestore", "dynamic-links", "crashlytics"], "peerDependencies": { "react": "*",