invertase / react-native-firebase

๐Ÿ”ฅ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[๐Ÿ›] iOS - Cannot receive any notifications before the app opens second time #4299

Closed jagwingchoy closed 4 years ago

jagwingchoy commented 4 years ago

Background

Here I am changing the notification service from appcenter to firebase.
I am building the app to my real device (iPhone XR) using Xcode in order to test notifications.

I have tried to search the issue from this issues board, stack overflow, and google, but still cannot find any related reports.

Project Files

index.js

import messaging from '@react-native-firebase/messaging';
messaging().setBackgroundMessageHandler(async (remoteMessage) => {});

import App from './App';

AppRegistry.registerComponent('sampleApp', () => App)

App.js

import messaging from '@react-native-firebase/messaging';

class App extends Component {
  requestUserPermission = async () => {
    const authStatus = await messaging().requestPermission();
    const enabled =
      authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
      authStatus === messaging.AuthorizationStatus.PROVISIONAL;

    console.log("notification authorized?", enabled);
  };

  async componentDidMount() {
    await this.requestUserPermission();

    /* Get the token and store in database */
    messaging().getToken().then((token) => {
      console.log("fcm token, need to store to backend database", token);
    });

    /* Success */
    const unsubscribe = messaging().onMessage(async remoteMessage => {
      console.log("Notification when app is on foreground", remoteMessage);
    });

    /* Success */
    messaging().onNotificationOpenedApp(remoteMessage => {
      console.log('Notification caused app to open from background state:', remoteMessage);
    });

    /* Success */
    messaging().getInitialNotification().then(remoteMessage => {
      if (remoteMessage) {
        console.log('Notification caused app to open from quit state:', remoteMessage);
      }
    });
  }

  render() {
    return (/* Blah blah blah */);
  }
}

export default App;

I have also built up a firebase-admin nodejs server for pushing notification:

const admin = require('firebase-admin');
const credential = require('./sample-firebase-adminsdk-aaaaaaaaaaa.json');

admin.initializeApp({ credential: admin.credential.cert(credential) });

/*
*/
function sendNotification(targets, title, message, badge = 1, imageUrl = null) {
  if (!Array.isArray(targets) || targets.length == 0) {
    throw new Error("Please provide non-empty targets tokens as Array.");
  }

  if (!title || !message) {
    throw new Error("Please provide title and message");
  }

  let notification = {
    tokens: targets,
    notification: {
      title: title,
      body: message
    },
    data: {},
    apns: {
      payload: {
        aps: {
          'mutable-content': 1,
          badge: badge,
          sound: 'default',
        }
      }
    }
  };

  if (imageUrl) {
    notification.apns.fcm_options = { image: imageUrl };
    notification.notification.imageUrl = imageUrl;
    notification.android = { notification: { image: imageUrl } };
  }

  admin.messaging().sendMulticast(notification).then((response) => {
    console.log('Successfully sent message:', response);
  }).catch((error) => {
    console.log('Error sending message:', error);
  });
}

Then I will call the function like below:

sendNotification(['device_firebase_message_token'], 'Hello World', 'If you see me, it is success!', 1, 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');

I surely follow the instructions to install the react-native-firebase and all firebase-cloud-messaging steps in https://rnfirebase.io/. (Also the image notification in iOS)

Issue Encountered

After I have built the app into my real device(iPhone XR) through Xcode,
I will open the debugger to get the fcm token from console.log(). No matter:

it cannot receive any notifications. The logs in nodejs function show it is success:

Successfully sent message: {
  responses: [
    {
      success: true,
      messageId: 'projects/sample-app/messages/0:xxxxxxxxxxxxxxxx'
    }
  ],
  successCount: 1,
  failureCount: 0
}

But after I completely quit the app from background and restart the app again, it can receive notifications normally. The logs also show it is success:

Successfully sent message: {
  responses: [
    {
      success: true,
      messageId: 'projects/sample-app/messages/xxxxxxxxxxxxxxxx'
    }
  ],
  successCount: 1,
  failureCount: 0
}

One thing I have noticed is: the message ID are always start with 0: when I cannot receive the notification.

Does anyone encountered this problem? And how to solve it?

Environment

Click To Expand

**`react-native info` output:** ``` React Native Environment Info: System: OS: macOS 10.15.6 CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz Memory: 181.42 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.14.0 - /usr/local/bin/node Yarn: 1.19.1 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 23, 24, 25, 26, 27, 28, 29 Build Tools: 26.0.2, 26.0.3, 27.0.3, 28.0.3, 29.0.2, 29.0.3 System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 12.0/12A7209 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.10 => 0.59.10 npmGlobalPackages: create-react-native-module: 0.19.0 react-native-cli: 2.0.1 react-native-rename: 2.4.1 ``` - **Platform that you're experiencing the issue on**: - [x] **iOS** but have not tested behavior on Android - **Dependencies in `package.json`** ``` "@react-native-firebase/app": "8.4.1", "@react-native-firebase/messaging": "7.8.4", "react": "16.8.3", "react-native": "0.59.10", "react-redux": "5.0.7", "redux": "3.7.2", ```

mikehardy commented 4 years ago

Try doing it without remote debugger, that causes the JS bundle to run in browser vs on device and the execution environment is pretty different. Also, you may need to wait a little bit - these processes are all asynchronous in the cloud though your success response from node does seem to indicate it should work.

adbario commented 4 years ago

I was having the same issue here on iOS with latest React Native and it seemed to persist even after uploading a production build to TestFlight. Downgrading the libraries solved the issue for me:

"@react-native-firebase/app": "^8.4.1" => "@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "^7.8.3" => "@react-native-firebase/messaging": "~7.5.0"

On iOS notifications were only received on second app launch and after, Android had no issues at all. I'm using the libraries exactly as @jagwingchoy, though having quite a bit more dependencies. Happy to add my environment details here once I'm back at work if it helps.

tomkelsey commented 4 years ago

Hey,

Just to add that I appear to be having the same issue.

"@react-native-firebase/app": "^8.4.3" "@react-native-firebase/messaging": "^7.8.6"

I've tried using the default Firebase iOS SDK version and also overriding to 6.32.2

On first install and open from TestFlight:

Hard closing the app and re-opening it appears to resolve the issue - sending the same message with the same FCM token via the Firebase console is successful.

Happy to add extra info if helpful ๐Ÿ‘

mikehardy commented 4 years ago

This sounds like the sort of thing that may need a reproduction using pure Obj-C (or Swift) and nothing but the native APIs to see if it's firebase-ios-sdk or us https://github.com/firebase/quickstart-ios/tree/master/messaging - that is a skeleton which should be trivial to build a repro on

JoaoPauloCMarra commented 4 years ago

Just to add more info, I am having the same issue with some devices. Works on iPhone 7, ios 14, iPhone 6s but not on X and 11 using the following:

    "@react-native-firebase/app": "^8.4.3",
    "@react-native-firebase/messaging": "^7.8.6",
tomkelsey commented 4 years ago

Disclaimer: I'm no native developer ๐Ÿ™ˆ

I had a go with the iOS quick start above and it seems to have the same issue which I guess points towards it being a firebase-ios-sdk problem?

This was my process:

I can repeat the above process and it always seems to be the same.

When testing the app without TestFlight and just running from Xcode to my device I experienced inconsistent results. Sometimes the notification is received on first install/open and other times I have to quit the app and re-open it. However, via TestFlight it seems to be consistently not working following the steps above.

mikehardy commented 4 years ago

To set expectations: for something inconsistently reproduced or device specific this really doesn't sound like a problem with the module and also sounds quite time-intensive to troubleshoot, I will spend no personal effort on finding the root cause but will happily merge a well-reasoned PR. I strongly suggest using the firebase-ios-sdk quickstart messaging sample to attempt reproduction without this module

JoaoPauloCMarra commented 4 years ago

for ppl that use performance and analytics, this is the combo that actually works for me(so far):

    "@react-native-firebase/analytics": "7.4.2",
    "@react-native-firebase/app": "~8.2.0",
    "@react-native-firebase/messaging": "~7.5.0",
    "@react-native-firebase/perf": "7.3.2",
ahmadworks commented 4 years ago

I have the exact same behaviour. on TestFlight version it never works after first install, you need to force quit the app and open it again to start receiving notificaitons. But on XCode run version it sometimes works after first install other times it never works. I tried every possible hack to fix it over the last week and I am not able to find any solution. Downgrading to App 8.2.0 and Messaging 7.5.0 fixed it but it's not a possible solution for me since it will break other things on my code.

mikehardy commented 4 years ago

@ahmadworks did you look at the changelog for the versions released between the version you downgraded to and the version not working for you? Did you try versions one by one (if there are more than one) to see exactly when it broke? Then you can go into the actual version (I keep releases very small so it is usually just one PR with a small change) to see what the difference was? Then you can try the current version but overriding the difference (either via patch-package or - more likely it was a firebase-ios-sdk change) to see if it works again

Finally, if it was code here you can point out the actual error, or if it was firebase-ios-sdk upgrading you can check their github for relevant issues and get an actual fix for the problem.

I don't think we changed much here in the versions you mention so this sounds like a firebase-ios-sdk problem. If you need to make a reproduction from them you need to do it based off one of their quickstarts: https://github.com/firebase/quickstart-ios/ - they won't accept react-native issues

fernandotakai commented 4 years ago

@tomkelsey i was having the exact same problem as you -- after a clean install, nothing was being called. force close the app, re-open, and my notifications would start working again

i just downgraded my app to the following versions:

"@react-native-firebase/analytics": "7.4.1",
"@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "~7.5.0",

Which in turn, changed some Podfile.lock versioning. This is what it looks like for firebase:

- Firebase/Analytics (6.27.1):
- Firebase/Core (6.27.1):
- Firebase/CoreOnly (6.27.1):
- Firebase/Messaging (6.27.1):
- FirebaseAnalytics (6.6.2):
- FirebaseCore (6.8.1):
- FirebaseCoreDiagnostics (1.5.0):
- FirebaseInstallations (1.5.0):
- FirebaseInstanceID (4.5.1):
- FirebaseMessaging (4.5.0):

I'm not really sure yet if it was related to RNFB or Firebase core. I'm working on their quickstart app to see if i can find anything there.

(btw, after i changed packages.json, i fully removed my node_modules, then i removed my Podfile.lock and then i reinstalled my pods. that did the trick)

jagwingchoy commented 4 years ago

I was having the same issue here on iOS with latest React Native and it seemed to persist even after uploading a production build to TestFlight. Downgrading the libraries solved the issue for me:

"@react-native-firebase/app": "^8.4.1" => "@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "^7.8.3" => "@react-native-firebase/messaging": "~7.5.0"

On iOS notifications were only received on second app launch and after, Android had no issues at all. I'm using the libraries exactly as @jagwingchoy, though having quite a bit more dependencies. Happy to add my environment details here once I'm back at work if it helps.

Thanks @adbario, I have downgraded to the versions you mentioned fixed the issue.

ahmadworks commented 4 years ago

@mikehardy please check this (https://github.com/leyserkids/cordova-plugin-firebase/commit/124dd7247dd55159b661759f27491819833bbb5b) it fixed the bug for Cordova users.

ewfian commented 4 years ago

@mikehardy please check this (leyserkids/cordova-plugin-firebase@124dd72) it fixed the bug for Cordova users.

I am the author of this commit. this issue has gone after this change, But I am not sure if itโ€™s really works well.

mikehardy commented 4 years ago

Thanks for the suggestion @ahmadworks and for checking in @ewfian interesting your uncertainty, I remember reading the changelog for the last ios sdk update and thinking "hmm looks like we have a fair bit of work to switch away from any of the instance ID APIs as they're moving that all under messaging", so to me this really looks like it aligns with the future direction of firebase-ios-sdk and if I were the firebase-ios-sdk team I wouldn't even accept the instance ID bug as a repro, I'd just direct you/us to the API in that commit

So to the point: is there anything specific you are uncomfortable with, or would a PR in this repo to make the analogous switch seem like the right thing? Seems like it would be right thing to me...

georgetk commented 4 years ago

@tomkelsey i was having the exact same problem as you -- after a clean install, nothing was being called. force close the app, re-open, and my notifications would start working again

i just downgraded my app to the following versions:

"@react-native-firebase/analytics": "7.4.1",
"@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "~7.5.0",

Which in turn, changed some Podfile.lock versioning. This is what it looks like for firebase:

- Firebase/Analytics (6.27.1):
- Firebase/Core (6.27.1):
- Firebase/CoreOnly (6.27.1):
- Firebase/Messaging (6.27.1):
- FirebaseAnalytics (6.6.2):
- FirebaseCore (6.8.1):
- FirebaseCoreDiagnostics (1.5.0):
- FirebaseInstallations (1.5.0):
- FirebaseInstanceID (4.5.1):
- FirebaseMessaging (4.5.0):

I'm not really sure yet if it was related to RNFB or Firebase core. I'm working on their quickstart app to see if i can find anything there.

(btw, after i changed packages.json, i fully removed my node_modules, then i removed my Podfile.lock and then i reinstalled my pods. that did the trick)

Had the same issue and this worked for me, thanks @adbario

mikehardy commented 4 years ago

Glad to hear there is a workaround but the most valuable thing anyone could do :pray: :pray: is take the change listed above and make a PR here that implemented the same switch to the different/new API

https://github.com/leyserkids/cordova-plugin-firebase/commit/124dd72

TPXP commented 4 years ago

We're also facing the same issue here and it seems somewhat dependent on the iDevice, since some of our test devices don't face the issue while others do.

Trying to switch to tokenWithCompletion and deleteDataWithCompletion did not help here, same issue. I'm not sure the mentioned PR really fixes the problem.

mikehardy commented 4 years ago

Interesting. I was operating under the assumption the referenced change from cordova ecosystem would resolve the issue. @TPXP - are you quite certain you attempted that patch cleanly (for example using npx react-native-clean-project to make absolutely sure the change was in effect? this is a common problem...).

If that PR doesn't fix the problem then, no, I don't just want a PR that rolls back changes, we learn nothing then.

What I want is a bisect on the versions (perhaps already done? I think we know the version to roll back to, indicating that the next version broke?) to know exactly which PRs are the problem (they're not listed yet unless I missed them?)

Then maybe a roll back PR, but I have a further hunch that it is a firebase-ios-sdk issue, so if the change in the PR that caused the problem is just bumping the firebase-ios-sdk we don't need a PR here at all. You just override the firebase-ios-sdk in your Podfile, but then we need a clean reproduction based on the quickstart directly against firebase-ios-sdk so we may get resolution

The general idea being: we can't just move backwards here. The underlying firebase SDKs move too quickly, and when we support the new APIs (which we must do) we become dependent on the new versions, moving back blindly is not a viable plan.

So I'm looking for any way to either stay current or log upstream issues vs current while moving allowing affected people to temporarily stay back.

TPXP commented 4 years ago

@mikehardy Here is the patch I applied. It breaks the scope feature but I don't need it in my app. https://gist.github.com/TPXP/c149253c2e549684a1e5abcf466b974d

I'm also betting this is a firebase ios SDK issue, especially since downgrading fixed the issue for some.

mikehardy commented 4 years ago

Related discussion of scope, which I/we think may be broken already and will likely be removed: https://github.com/invertase/react-native-firebase/issues/3714#issuecomment-701597723 - I did a quick scan of the firebase-ios-sdk repo code and couldn't quickly + authoritatively say we're using the APIs right but that's mostly because the codebase is gigantic and I ran out of time. My goal with that was to see exactly how they are fetching tokens on app startup to make sure we're doing the same - I think their APIs all just moved here so perhaps we're still using the older (now-deprecated) APIs and their current release has only tested the new APIs thoroughly (that would imply there's a bug in the older APIs, could happen?). Nothing concrete to say though, sorry, and I'm out of time on this one for a while

ewfian commented 4 years ago

I have tested it many times on different devices in the past few days and it has worked well through this modification https://github.com/leyserkids/cordova-plugin-firebase/commit/124dd72

One point that needs to be explained is that I called [[UIApplication sharedApplication] registerForRemoteNotifications]; before [[FIRMessaging messaging] tokenWithCompletion:] The code line is shown here: https://github.com/leyserkids/cordova-plugin-firebase/blob/124dd7247dd55159b661759f27491819833bbb5b/src/ios/FirebasePlugin.m#L31

Call this method to initiate the registration process with Apple Push Notification service. If registration succeeds, the app calls your app delegate objectโ€™s application:didRegisterForRemoteNotificationsWithDeviceToken: method and passes it a device token. (https://developer.apple.com/documentation/uikit/uiapplication/1623078-registerforremotenotifications?language=objc)

This is because I want to provide users with a reset button when they complain about not receiving the push. It will call [[UIApplication sharedApplication] unregisterForRemoteNotifications];, [[FIRMessaging messaging] deleteDataWithCompletion:], [[UIApplication sharedApplication] registerForRemoteNotifications];, [[FIRMessaging messaging] tokenWithCompletion: in turn.

I'm not sure if this method call triggered the FCM associated APNs token. You guys can try to add this and try to find if itโ€™s effective.

As @mikehardy says:

My goal with that was to see exactly how they are fetching tokens on app startup to make sure we're doing the same

How APNs token and FCM are associated is unclear. If anyone knows the principle, can you explain it? When I can't receive the push by using the FCM, I directly using the APNs as same app instance with nothing to do, it always works.

TPXP commented 4 years ago

You're raising an interesting point with device registration. It should work out of the box since Firebase is supposed to automatically register for remote notifications, perhaps the SDK has an issue there. I'll try to register manually with messaging().registerDeviceForRemoteMessages(); and we'll see if that fixes it.

Regarding the link between APNS tokens and FCM Tokens, the latter is derived from the first. Yet if there is no APNS token, Firebase will still generate a (broken) token - that's what happens in the simulator for example.

rawatnaresh commented 4 years ago

@tomkelsey i was having the exact same problem as you -- after a clean install, nothing was being called. force close the app, re-open, and my notifications would start working again

i just downgraded my app to the following versions:

"@react-native-firebase/analytics": "7.4.1",
"@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "~7.5.0",

Which in turn, changed some Podfile.lock versioning. This is what it looks like for firebase:

- Firebase/Analytics (6.27.1):
- Firebase/Core (6.27.1):
- Firebase/CoreOnly (6.27.1):
- Firebase/Messaging (6.27.1):
- FirebaseAnalytics (6.6.2):
- FirebaseCore (6.8.1):
- FirebaseCoreDiagnostics (1.5.0):
- FirebaseInstallations (1.5.0):
- FirebaseInstanceID (4.5.1):
- FirebaseMessaging (4.5.0):

I'm not really sure yet if it was related to RNFB or Firebase core. I'm working on their quickstart app to see if i can find anything there.

(btw, after i changed packages.json, i fully removed my node_modules, then i removed my Podfile.lock and then i reinstalled my pods. that did the trick)

I'm getting this warning when i downgrade to @react-native-firebase/app": "~8.2.0", Screen Shot 2020-10-05 at 10 02 34

mikehardy commented 4 years ago

Of course, if you downgrade app you'll be implicitly breaking the expected peer-dependency. That won't happen quietly, you will need to understand the changes you're cutting out by downgrading app and test to make sure things still work for you. We have success reports here so they should work but the warning is real.

TPXP commented 4 years ago

I'll try to register manually with messaging().registerDeviceForRemoteMessages(); and we'll see if that fixes it.

That didn't fix it. Perhaps only on iOS 14 ?

ewfian commented 4 years ago

I have tested it many times on different devices in the past few days and it has worked well...

@TPXP Here are devices i tested

kuznetsov-from-wonderland commented 4 years ago

I have the save issue

"@react-native-firebase/app": "^8.4.5", "@react-native-firebase/messaging": "^7.8.11",

any solutions?

mikehardy commented 4 years ago

@kromsik quite a few above. How did it go when read them and tried them?

Jobeso commented 4 years ago

This issue is very likely a bug in the firebase-ios-sdk as https://github.com/firebase/firebase-ios-sdk/issues/6553 suggests. It has the same behaviour as described here just using the native sdk.

TPXP commented 4 years ago

@ewfian In my case, I believe this was caused by the Intercom SDK, perhaps it was trying to swizzle the same methods the Firebase iOS SDK uses to get push notifications to work. After removing the Intercom SDK on iOS (but keeping the patch I linked above), push notifications seem to work again. We'll keep testing, but I'm guessing we were playing with fire trying to get push notifications to work for 2 components. Since the Intercom chat is not a strong requirement, we just dropped the Intercom SDK but if we need it again, we'll try to disable method swizzling in this SDK.

In any case, thanks for your help and for providing your test results. They probably led me to attempting removing the Intercom SDK :smile:

tomkelsey commented 4 years ago

Hi all,

I experienced this issue in react-native-firebase and followed @mikehardy's suggestion of trying to recreate in the quickstart app using the underlying firebase-ios-sdk

I had the same problem in the quickstart app so I created this issue: https://github.com/firebase/firebase-ios-sdk/issues/6553

After lots of logs and some great help from the people over there I believe the underlying issue has now been resolved with this PR: https://github.com/firebase/firebase-ios-sdk/pull/6669

There may be a better way, but to get this working for me and our setup I made the following changes to our Podfile:

This is using the latest released versions of react-native-firebase.

Whilst you're welcome to use my fork to test if it works I wouldn't recommend relying on it as I may not maintain it and it could disappear. Hopefully it won't be required once a new version of firebase-ios-sdk is released.

For me the issue was intermittent so I'd be cautious of whether or not some of the proposed fixes above actually fixed it or it just coincidentally worked for a period of time afterwards. I've tested this underlying fix quite extensively but it could of course also be susceptible to the same problem so would be grateful if more people could test it and see how they get on :)

mikehardy commented 4 years ago

They release about weekly so hopefully it will be out soon thank you for driving this to a solution that is huge

mikehardy commented 4 years ago

@tomkelsey I've got this up against the new release-6.34.0 branch in a stable spot against Invertase firebase-ios-sdk fork here:

https://github.com/invertase/firebase-ios-sdk/commits/release-6.34.0-patched

That tree is the result of the (now approved!) 5 commits from the PR cherry-picked onto the release-6.34.0 branch

I confirm things build and appear to run successfully when I add this to my Podfile:

pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'

...assuming you cd ios && rm -f Podfile.lock && pod install --repo-update to make sure everything has solid references to 6.34.0 which is brand new

The complete firebase-related Podfile chunk looks like this for interested people:

  # Set up Firebase SDK version
  $FirebaseSDKVersion = '6.34.0'
  # OPTIONAL include this if you want to try speeding up Firestore compile times. May cause Xcode 12 to have issues. OPTIONAL.
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => $FirebaseSDKVersion
  # Include temporary fix already merged upstream but not released, to get tokens on first app open
  pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'
kuznetsov-from-wonderland commented 4 years ago

@tomkelsey I've got this up against the new release-6.34.0 branch in a stable spot against Invertase firebase-ios-sdk fork here:

https://github.com/invertase/firebase-ios-sdk/commits/release-6.34.0-patched

That tree is the result of the (now approved!) 5 commits from the PR cherry-picked onto the release-6.34.0 branch

I confirm things build and appear to run successfully when I add this to my Podfile:

pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'

...assuming you cd ios && rm -f Podfile.lock && pod install --repo-update to make sure everything has solid references to 6.34.0 which is brand new

The complete firebase-related Podfile chunk looks like this for interested people:

  # Set up Firebase SDK version
  $FirebaseSDKVersion = '6.34.0'
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => $FirebaseSDKVersion
  pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'

That did not work for me. With, of course

cd ios && rm -f Podfile.lock && pod install --repo-updat
kuznetsov-from-wonderland commented 4 years ago

@tomkelsey i was having the exact same problem as you -- after a clean install, nothing was being called. force close the app, re-open, and my notifications would start working again

i just downgraded my app to the following versions:

"@react-native-firebase/analytics": "7.4.1",
"@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "~7.5.0",

Which in turn, changed some Podfile.lock versioning. This is what it looks like for firebase:

- Firebase/Analytics (6.27.1):
- Firebase/Core (6.27.1):
- Firebase/CoreOnly (6.27.1):
- Firebase/Messaging (6.27.1):
- FirebaseAnalytics (6.6.2):
- FirebaseCore (6.8.1):
- FirebaseCoreDiagnostics (1.5.0):
- FirebaseInstallations (1.5.0):
- FirebaseInstanceID (4.5.1):
- FirebaseMessaging (4.5.0):

I'm not really sure yet if it was related to RNFB or Firebase core. I'm working on their quickstart app to see if i can find anything there.

(btw, after i changed packages.json, i fully removed my node_modules, then i removed my Podfile.lock and then i reinstalled my pods. that did the trick)

I've tried to do the same

The only thing I've not tried is to run Production build from Test Flight.

JoaoPauloCMarra commented 4 years ago

@tomkelsey I've got this up against the new release-6.34.0 branch in a stable spot against Invertase firebase-ios-sdk fork here:

https://github.com/invertase/firebase-ios-sdk/commits/release-6.34.0-patched

That tree is the result of the (now approved!) 5 commits from the PR cherry-picked onto the release-6.34.0 branch

I confirm things build and appear to run successfully when I add this to my Podfile:

pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'

...assuming you cd ios && rm -f Podfile.lock && pod install --repo-update to make sure everything has solid references to 6.34.0 which is brand new

The complete firebase-related Podfile chunk looks like this for interested people:

  # Set up Firebase SDK version
  $FirebaseSDKVersion = '6.34.0'
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => $FirebaseSDKVersion
  pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'

I tried the suggestion and now I am receiving the Notifications, still, early tests, only on testflight so will continue with the tests and report back.

(Testflight) Tested on:
iPhone 6s iPhone 7 iPhone 11

One found the issue is: Notification data I can only access after hard close and open a second time.

trungnguyen1791 commented 4 years ago

@JoaoPauloCMarra Did you have any update about this issue?

JoaoPauloCMarra commented 4 years ago

@JoaoPauloCMarra Did you have any update about this issue?

not yet, I can only get the notification data on the second start.

tomkelsey commented 4 years ago

@mikehardy heads up that there was an issue with the firebase-ios-sdk PR causing a crash. It's been resolved by https://github.com/firebase/firebase-ios-sdk/pull/6737 so you may want to update your patched version ๐Ÿ‘

mikehardy commented 4 years ago

Definitely bleeding edge stuff here, I'm not entirely surprised. Thanks very much for the heads-up @tomkelsey !

I've cherry-picked the follow-on commit to the same branch

If people are relying on the commit hash to have reproducible builds they will need to update it: https://github.com/invertase/firebase-ios-sdk/commit/4ee7309f7e290f0d578a3470fe35201d41241b63

Otherwise I think you may have to delete Podfile.lock and reinstall to get the update

trungnguyen1791 commented 4 years ago

@JoaoPauloCMarra Did you have any update about this issue?

not yet, I can only get the notification data on the second start.

In my test, there is always a case that:

  1. First fresh install -> Doesn't work because cachedTokenIfAvailable != nil but cachedTokenInfos is nil. And app can't invalidate cached token.
  2. Second fresh install -> Work normal because cachedTokenIfAvailable = nil -> defaultHandler get call -> Register request sent......
  3. Third fresh install -> same as the (1) 4 And so on....

Is there a chance that keychain storage get deleted before cachedTokenInfos get call.

czuiko commented 4 years ago

I had the same problem with iOS under react native. I was build app with changed podfile and it helped me


$FirebaseSDKVersion = '6.34.0'
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => $FirebaseSDKVersion
pod 'FirebaseInstanceID', :git => 'https://github.com/invertase/firebase-ios-sdk.git', :branch => 'release-6.34.0-patched'
``
shayantabatabaee commented 4 years ago

I have the similar issue, please kindly test this solution and let me know if it works.

https://github.com/firebase/firebase-ios-sdk/issues/6766#issuecomment-712760190

bfelbo commented 4 years ago

@mikehardy Thanks a lot for your investigation into this issue! It seems like the PR fixing the issue in firebase-ios-sdk was merged 26 days ago and the fix was included in the latest release published seven days ago. Would it be possible to release a new version of RN Firebase with this fixed?

That would be super helpful!

EDIT: Just saw https://github.com/invertase/react-native-firebase/pull/4471 - amazing that you're already on it!

bfelbo commented 4 years ago

Has anyone else seen very strange behavior on Firebase analytics as part of this bug?

image

We know that we're affected by this bug, but we wanna make sure that it's the only bug affecting us. The graph above shows that after upgrading to 7.9.0 on Oct 20, Firebase now thinks that we've received many more data push messages than we've sent. How that's possible I don't know ๐Ÿ˜„

Would be awesome to hear if anyone else facing this bug are seeing the same strange behavior on Firebase analytics?

zrg-team commented 4 years ago

the issue still there? In the current messaging version, ios sometimes can not registerDeviceForRemoteMessages due to missing the device token.

JoaoPauloCMarra commented 4 years ago

did anyone found a workaround/fix for this one?

mikehardy commented 4 years ago

@JoaoPauloCMarra yes, we all did. And we implemented it here in an Invertase-hosted firebase-ios-sdk fork with the upstream fix integrated. And detailed how to integrate that into your local project. It's in the comments above

JoaoPauloCMarra commented 4 years ago

@mikehardy have you read this one? https://github.com/invertase/react-native-firebase/issues/4299#issuecomment-707609612