Skip to content

v2.0.0#130

Merged
Salakar merged 147 commits intomasterfrom
v2
Jun 21, 2017
Merged

v2.0.0#130
Salakar merged 147 commits intomasterfrom
v2

Conversation

@Salakar
Copy link
Contributor

@Salakar Salakar commented May 27, 2017

Migration guide

A guide to upgrading from v1 to v2 can be found on the docs here.

Change Log

Version 2.0.0 of RNFirebase introduces a new features, breaking changes, deprecations (matching v4 of the web SDK) and general build / dependency improvements.

New Features

Ads

  • [android] Implemented Admob Banner view
  • [both] Implemented Admob Interstitials
  • [both] Implemented Admob Rewarded Video
  • [android] Implemented Admob Native Express

Performance Monitoring

RNFirebase now supports the recently released Performance Monitoring module. Much like Crash Reporting, automatic events (traces) are delivered to your console whilst providing support to register custom traces. See the documentation on how to use this in your app.

Implemented methods:

  • setPerformanceCollectionEnabled(enabled: boolean)
  • newTrace(id: string): Trace
  • Trace.start(): void
  • Trace.incrementCounter(event: string): void
  • Trace.stop(): void

Remote Config

  • [both] Implemented remote config in v1.1.0 - adding here for sake of completeness. Documentation

Auth

Crash

  • [android] Implemented new crash log disabling methods.

Bug Fixes

  • [js] Fixed an issue whereby the result of onAuthStateChange returned a different result on state changes.

Breaking Changes & Deprecations

  • [breaking] RNFirebase v2.0.0 drops support for React Native versions less than v40
  • [deprecated] providerId should now be used instead of provider whilst obtaining auth credentials. The latter will be removed in future releases.
  • [deprecated] Deprecated User.getToken in favour of User.getIdToken.
  • [breaking] User.reauthenticate has been removed in favour of User.reauthenticateWithCredential.
  • [breaking] User.link has been removed in favour of User.linkWithCredential.
  • [breaking] Removed unnecessary didReceiveNotificationResponse and willPresentNotification methods for iOS messaging. Added additional didReceiveRemoteNotification method.
  • [breaking] firebase.messaging().onTokenRefresh and firebase.messaging().onMessage return a function to unsubscribe as per the Web SDK spec: https://firebase.google.com/docs/reference/js/firebase.messaging.Messaging#onMessage. Previously they returned an object with a .remove() method.

Android

All firebase modules are now optional so you only need to import the Firebase functionality that you require in your application.

You need to make a couple of changes to your app/build.gradle file. Update the react-native-firebase compile statement to read:

compile(project(':react-native-firebase')) {
  transitive = false
}
compile "com.google.firebase:firebase-core:11.0.0"

Add each of the firebase modules you need from the following list:

compile "com.google.firebase:firebase-ads:11.0.0"
compile "com.google.firebase:firebase-analytics:11.0.0"
compile "com.google.firebase:firebase-auth:11.0.0"
compile "com.google.firebase:firebase-config:11.0.0"
compile "com.google.firebase:firebase-crash:11.0.0"
compile "com.google.firebase:firebase-database:11.0.0"
compile "com.google.firebase:firebase-messaging:11.0.0"
compile "com.google.firebase:firebase-perf:11.0.0"
compile "com.google.firebase:firebase-storage:11.0.0"

Update MainApplication.java and import the modules as required:

import io.invertase.firebase.admob.RNFirebaseAdMobPackage; //Firebase AdMob
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; // Firebase Analytics
import io.invertase.firebase.auth.RNFirebaseAuthPackage; // Firebase Auth
import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage; // Firebase Remote Config
import io.invertase.firebase.crash.RNFirebaseCrashPackage; // Firebase Crash Reporting
import io.invertase.firebase.database.RNFirebaseDatabasePackage; // Firebase Realtime Database
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // Firebase Cloud Messaging
import io.invertase.firebase.perf.RNFirebasePerformancePackage; // Firebase Performance Monitoring
import io.invertase.firebase.storage.RNFirebaseStoragePackage; // Firebase Storage

Add the packages to the getPackages() method as required:

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNFirebasePackage(),  // <-- Add this line
          // Add these packages as appropriate
          new RNFirebaseAdMobPackage(),
          new RNFirebaseAnalyticsPackage(),
          new RNFirebaseAuthPackage(),
          new RNFirebaseRemoteConfigPackage(),
          new RNFirebaseCrashPackage(),
          new RNFirebaseDatabasePackage(),
          new RNFirebaseMessagingPackage(),
          new RNFirebasePerformancePackage(),
          new RNFirebaseStoragePackage()
      );
    }

iOS

All firebase modules are now optional so you only need to import the Firebase functionality that you require in your application. Simply update your Podfile to only include the Firebase modules for functionality that you require in your app.

Ehesp and others added 30 commits May 24, 2017 08:42
@Salakar Salakar mentioned this pull request Jun 20, 2017
@D1no
Copy link
Contributor

D1no commented Jun 21, 2017

Update: It's apperant that yarn is not pulling the right branch. Hence the old header file with the missing class.

I installed react-native-firepase via
"react-native-firebase": "invertase/react-native-firebase#v2",

Original Problem Description

Details I run into the following issue with cloud messaging `/AppDelegate.m:52:24: No known class method for selector 'didReceiveRemoteNotification:'`

image

Implementing Cloud Messaging according to
https://github.com/invertase/react-native-firebase/blob/v2/docs/installation-ios.md#34-update-appdelegatem

3.3) Update AppDelegate.h

Add the following import:

@import UserNotifications;

Change the interface descriptor to:

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

3.4) Update AppDelegate.m

Add the following import:

#import "RNFirebaseMessaging.h"

Add the following to the didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method after [FIRApp Configure]:

[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

Add the following methods:

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFirebaseMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

Changing #import "RNFirebaseMessaging.h" to #import <RNFirebaseMessaging.h> does not lead to a change.

When cmd+click on RNFirebaseMessaging.h brings me to

#ifndef RNFirebaseMessaging_h
#define RNFirebaseMessaging_h
#endif

#import <UIKit/UIKit.h>

#import "Firebase.h"

#if __has_include(<React/RCTEventEmitter.h>)
#import <React/RCTEventEmitter.h>
#else // Compatibility for RN version < 0.40
#import "RCTEventEmitter.h"
#endif
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#else // Compatibility for RN version < 0.40
#import "RCTBridgeModule.h"
#endif
#if __has_include(<React/RCTUtils.h>)
#import <React/RCTUtils.h>
#else // Compatibility for RN version < 0.40
#import "RCTUtils.h"
#endif

@import UserNotifications;

@interface RNFirebaseMessaging : NSObject <RCTBridgeModule>

typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result);
typedef void (^RCTWillPresentNotificationCallback)(UNNotificationPresentationOptions result);
typedef void (^RCTNotificationResponseCallback)();

@property (nonatomic, assign) bool connectedToFCM;

#if !TARGET_OS_TV
+ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler;
+ (void)didReceiveLocalNotification:(nonnull UILocalNotification *)notification;
+ (void)didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response withCompletionHandler:(nonnull RCTNotificationResponseCallback)completionHandler;
+ (void)willPresentNotification:(nonnull UNNotification *)notification withCompletionHandler:(nonnull RCTWillPresentNotificationCallback)completionHandler;
#endif

@end

@Cretezy
Copy link
Contributor

Cretezy commented Jun 21, 2017

@D1no have you tried deleting your node_modules AND your yarn.lock?

You may always want to try to pin to the latest commit on v2 (currently 9ed0a31b679b667a1af3388ebbcd4c4e5ec2235c), by doing invertase/react-native-firebase#9ed0a31b679b667a1af3388ebbcd4c4e5ec2235c and then resetting node_modules and yarn.lock (or the npm counterpart).

@Salakar
Copy link
Contributor Author

Salakar commented Jun 21, 2017

Am currently in the process of releasing this so you shouldn't have these probs in a moment.

@D1no
Copy link
Contributor

D1no commented Jun 21, 2017

Yes, a clean install. That is the reason I was surprised.

Edit: Awesome @Salakar 😁 than I discard now the yarn via git@ install. I go and get a coffee 🙏

Edit2: Yeah, pinning to commit is what I did to fix it.

@Salakar Salakar merged commit 6f9cfd6 into master Jun 21, 2017
@Salakar Salakar deleted the v2 branch June 21, 2017 15:36
@Salakar Salakar changed the title v2 [WIP] v2.0.0 Jun 21, 2017
@Salakar
Copy link
Contributor Author

Salakar commented Jun 21, 2017

@D1no @Cretezy @mikelambert @jasan-s @HofmannZ @sraka1 v2 has been published 🎉

A guide to upgrading from v1 to v2 can be found on the docs here.

@sraka1
Copy link

sraka1 commented Jun 21, 2017

@Salakar Cool! 🎉

Btw, "confirmPasswordReset" and "applyActionCode" are still missing in Auth. If they aren't added earlier, I will open a PR once I migrate to v2 next week (currently running a fork of the predecessor of this repo).

Also, any plans on supporting Dynamic Links in the future? 😄

@Salakar
Copy link
Contributor Author

Salakar commented Jun 21, 2017

@sraka1 we'll add those two auth functions to a minor/patch version in the next few days unless you beat us to it 😸 - we wanted to get v2 out the door rather than constantly adding to the todo list and v2 being delayed further.

We've yet to look into links, the next priority feature wise for us is js side firebase app configuration (no more plist/json fiddling) and with that mutli firebase app support.

@D1no
Copy link
Contributor

D1no commented Jun 21, 2017

Super Awesome 🚀 ! Firebase Invites than App Indexing are certainly super interesting. Dynamic Links is really a question of how that enters the void of react native navigators (we use flux navigator).

We've yet to look into links, the next priority feature wise for us is js side firebase app configuration (no more plist/json fiddling) and with that mutli firebase app support.

Well, not sure if that is so relevant. All the firebase sdk related material are always surrounded by the plist / json part. Not sure if the abstraction is something worth adding as a new fault line if people start to rely on it.

  • Since we can not use multiple targets, all files are linked to the same xcode target. That can cause issues when including files that should (for simplicity) be of the same reference but vary between builds. Such an example is the GoogleService-Info.plist for google login (you could reference them in your AppDelegate file). However, we try to touch as little of the native code as possible to have little hassle in upgrading further rn-versions. The best way to solve such situations is to have an extra folder in your ios/ folder, which is not added to the xcode project. And have files, depending on their build config suffix be copied to the app at build time. I.e. we manage our firebase files like so:
    manage files
    Here our script (simple shell command):
cp ${SRCROOT}/firebase/GoogleService-Info-${CONFIGURATION}.plist ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleService-Info.plist

From: facebook/react-native#11813 (comment)

@Salakar
Copy link
Contributor Author

Salakar commented Jun 21, 2017

@D1no it's another step in the direction of making it compatible with the web sdk, plus would be a lot less effort required for beginners (something we get a lot of).

Additionally it would allow initialising multiple firebase instances at the same time - just like the web, which has its use cases and has been requested before. Plist/json support will still remain if people want to use it though.

And finally also simplifies switching firebase instances per environment e.g. one for dev one for prod.

Doesn't mean however that we're not gonna look into Dynamic Links / App Indexing - there's 3 of us working on the project ;p I'm just tackling the above next myself

@D1no
Copy link
Contributor

D1no commented Jun 21, 2017

This was not an intended pull on priorities. Being able to change environments at runtime could be interesting though 🤔 codepush...cough...

@Salakar
Copy link
Contributor Author

Salakar commented Jun 21, 2017

@D1no no worries was just stating the reasoning behind it that's all. Flipping projects over via codepush would be cool 😸

@Salakar Salakar mentioned this pull request Jun 22, 2017
@aarongreenwald
Copy link

@D1no to piggyback on what @Salakar said - I'm one of the people requesting configurability on JS side, although I asked for it after @Salakar wrote that comment :)

I explained my reasoning in this comment. This isn't just for different environments (although that's a valid use case), it's for runtime production configuration. I don't think code push would even work. So it's definitely a really useful thing to have :)

@Salakar
Copy link
Contributor Author

Salakar commented Jul 5, 2017

@sraka1

Btw, "confirmPasswordReset" and "applyActionCode" are still missing in Auth. If they aren't added earlier, I will open a PR once I migrate to v2 next week (currently running a fork of the predecessor of this repo).

Implemented as of v2.0.2 - as well as checkActionCode.

@afilp
Copy link

afilp commented Mar 23, 2018

About code-push, I created an issue there:

microsoft/react-native-code-push#1185 (comment)

I believe there can be an "AsyncStorage" usage for applying some settings (like dynamic links) again after code-push is triggered.

What do you think?

@Salakar
Copy link
Contributor Author

Salakar commented Mar 23, 2018

@D1no just thought you might like to know as of v4 Firebase Dynamic Links and Firebase Invites are supported: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-rc.2 . We've yet to look at App Indexing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.