Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] iOS - Cannot receive any notifications before the app opens second time #4299

Closed
1 task done
jagwingchoy opened this issue Sep 23, 2020 · 77 comments
Closed
1 task done
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). platform: ios plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: bug New bug report

Comments

@jagwingchoy
Copy link

jagwingchoy commented Sep 23, 2020

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:

  • I push the notification through firebase console or my own built nodejs function
  • The app is foreground, background or quit state

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:
    • 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",
@jagwingchoy jagwingchoy added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Sep 23, 2020
@mikehardy
Copy link
Collaborator

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
Copy link

adbario commented Sep 23, 2020

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
Copy link

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:

  • I can send a notification with the APNS token direct and it's successful.
  • If I try and use the FCM token to send a notification via the Firebase console it never appears on the device.

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
Copy link
Collaborator

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
Copy link

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
Copy link

tomkelsey commented Sep 24, 2020

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:

  • Built and deployed the iOS quick start app to TestFlight.
  • Deleted any existing version of the iOS quick start app.
  • Restarted device
  • Installed the app from TestFlight
  • Allowed notifications and retrieved the FCM Token
  • Backgrounded the app
  • Sent a test message (with just title and notification text set to "Test") to the FCM Token via Firebase console
  • No notification received.
  • Force quit the app.
  • Re-open the app.
  • Background the app.
  • Send another message via Firebase console to same FCM token
  • Notification received

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
Copy link
Collaborator

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
Copy link

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
Copy link

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
Copy link
Collaborator

@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
Copy link

@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
Copy link
Author

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
Copy link

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

@ewfian
Copy link

ewfian commented Sep 29, 2020

@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
Copy link
Collaborator

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...

@mikehardy mikehardy added platform: ios plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Workflow: Waiting for User Response Blocked waiting for user response. labels Sep 29, 2020
@georgetk
Copy link

@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
Copy link
Collaborator

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

leyserkids/cordova-plugin-firebase@124dd72

@mikehardy mikehardy added Resolution: Solution Provided Workflow: Needs Review Pending feedback or review from a maintainer. labels Sep 30, 2020
@TPXP
Copy link
Contributor

TPXP commented Oct 1, 2020

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
Copy link
Collaborator

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
Copy link
Contributor

TPXP commented Oct 1, 2020

@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
Copy link
Collaborator

Related discussion of scope, which I/we think may be broken already and will likely be removed: #3714 (comment) - 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
Copy link

ewfian commented Oct 2, 2020

I have tested it many times on different devices in the past few days and it has worked well through this modification
leyserkids/cordova-plugin-firebase@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.

@rezasazesh
Copy link

@mikehardy Thanks for your help! The 'release-6.34.0-patched' solution does not work for me, I saw some people mentioned downgrading as a temporary measure but I will need to downgrade all other modules of react-native-firebase that I currently use also as they depend on "@react-native-firebase/app": "^8.4.7"

How do I know what version of packages below works with "@react-native-firebase/app": "^8.2.0"

   "@react-native-firebase/analytics": "^7.6.9",
    "@react-native-firebase/app": "^8.4.7",
    "@react-native-firebase/auth": "^9.3.2",
    "@react-native-firebase/database": "^7.5.13",
    "@react-native-firebase/firestore": "^7.9.1",
    "@react-native-firebase/functions": "^7.4.10",
    "@react-native-firebase/in-app-messaging": "^7.5.8",
    "@react-native-firebase/messaging": "^7.9.2",

@Donhv
Copy link

Donhv commented Nov 10, 2020

i have same issue. on first time install app, i can see notification on background but function messaging().onMessage / messaging().onNotificationOpenedApp never trigger. and The 'release-6.34.0-patched' solution does not work for me

@Donhv
Copy link

Donhv commented Nov 10, 2020

Yes, I have read every single comment in this repository for approximately a year.
Feel free to integrate the forward-port PR #4471 if your testing shows you still have problems with the solution here. I haven't had problems, personally.

this solution does not work for me. i can only see notification on background and cannot access notification data.

@mikehardy
Copy link
Collaborator

A simpler way is to look at the firebase-ios-sdk release notes to find the first version they introduced the bug, then override firebase-ios-sdk versions in your Podfile to use that one. I'm not sure what version that it is though, I'm more focused on moving forward / forward-porting sorry

@mikehardy
Copy link
Collaborator

#4471 has landed and is released, this should be solved now.

Pay VERY CAREFUL attention to the breaking changes notes on https://rnfirebase.io/releases/ in case you need to forward-port any of the APIs you are using (or drop them, if they were deprecated)

Any testing feedback would be welcome

Note that if you use on-device inference from ml-vision or ml-natural-language you will need to wait until react-native-mlkit gets that functionality re-homed (it is my next task), but if you use cloud inference you can migrate directly to the new consolidated @react-native-firebase/ml package

Cheers

@Donhv
Copy link

Donhv commented Nov 11, 2020

@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 😄

exactly, after remove Intercom SDK, i can access data notification on first time open app.
but u can fix it with out remove intercom by Manually handle push notifications (Optional)
https://developers.intercom.com/installing-intercom/docs/ios-push-notifications

@mikehardy
Copy link
Collaborator

mikehardy commented Nov 11, 2020

I'm sorry, I won't have time to debug interaction issues between a 3rd party product and react-native-firebase - it just isn't a priority

It may help to test with the most up to date firebase-ios-sdk though, check this release note: https://firebase.google.com/support/release-notes/ios#fcm (on the 7.1.0 release)

Also / in addition - if anyone could document the workaround it would help others, perhaps here? https://rnfirebase.io/faqs-and-tips - or maybe we need a new page for interaction between other messaging packages

If there is actually a problem with the way this module swizzles AppDelegate handlers then we can merge PRs to fix it but they will have to be contributed + tested by the community (that's you all, here)

@obernal
Copy link

obernal commented Jan 6, 2021

Thank for working on resolving this @mikehardy I tried the latest release and the issue was solved on the device I was testing. However, it turns out I'm still seeing something similar in some devices. @jagwingchoy it's very consistent that for those messages which aren't delivered (sometimes they are delivered but delayed by a LOT) I get a message id that starts with :0 were you ever able to figure out what that means? I suspect this might happen when FCM cannot actually establish a connection to the device so it might be just a problem of the device's network connectivity I'm seeing. Not sure, can't find anything about it on Firebase's Documentation.

@mikehardy
Copy link
Collaborator

Very important to note that FCM never establishes a connection to iOS devices any more - direct channel FCM was removed from iOS. It is always FCM -> APNs -> device. I'm not sure that has bearing or not, but maintaining clarity in mental models is critical in keeping universe of possible causes/effects manageable...

@trantrongkim98
Copy link

My project was don't received notification before opens second time on production build.
Who can help me?

@trantrongkim98
Copy link

trantrongkim98 commented Oct 15, 2021

My app use react-native-notification-badge to update badge of ios and it use APNs so conflict with firebase-messaging.
So i changed a different module and it worked for me

@mikehardy
Copy link
Collaborator

You might like notifee.app - fully open source now, and supports badging on iOS, https://notifee.app/react-native/docs/ios/badges - not as simple as that notification package, but should not conflict with firebase messaging

@gulsher7
Copy link

My project was don't received notification before opens second time on production build. Who can help me?

same here.. do you find any workaround

@Donhv
Copy link

Donhv commented Oct 24, 2021

My project was don't received notification before opens second time on production build. Who can help me?

same here.. do you find any workaround

pls check my comment #4299 (comment)

@justinkchen
Copy link

So what was the resolution here? seems like its still been kind of ongoing still? And I know it affects Testflight, does that mean it affects an app store release the same as well?

@mikehardy
Copy link
Collaborator

@justinkchen all the development is in the open. You may read the comments and determine status. I just did, it seemed like a subtle interaction of 3rd party providers that you are other affected users would need to inspect and drive to a root cause if desired. It's not reproducible in a stock app and does not appear to be caused by the module, or at least not demonstrably so yet. I'm open to collaborate with anyone on PRs if they are proposed.

@justinkchen
Copy link

Hmm okay I don't really have any other 3rd party provider that I can think of that would interfere. I saw some other thread somewhere else in the searching of this talking about how the permission of allowing notifications was coming after firebase was initialized and how that might be causing it so that firebase messaging not working until force restart of the app. Is there any validity to that idea? If so, any ideas how we could reinitialize firebase or somehow have that permission checked before firebase initializes?

@mikehardy
Copy link
Collaborator

There's a lot of speculation there for something I haven't seen 🤷 - that always leads me to:
https://stackoverflow.com/help/minimal-reproducible-example
that is, an index.js/App.js that drop cleanly into a fresh + clean app https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

@justinkchen
Copy link

Thanks Mike! I'll try to see what I can do to get it into a minimal state. I'm currently getting very consistent behavior of working 100% of the time on builds directly to phone, 100% of new app install from TestFlight doesn't work on first acceptance of permission but works after a force quit and reopen, and I'm waiting on a deploy to app store to confirm if it's same behavior as the TestFlight scenario.

@mikehardy
Copy link
Collaborator

@justinkchen seems like an onerous test cycle. Is the AppStore build not equivalent to a local release build, installed on phone? If not, why not? A reproduction that involves releasing via TestFlight isn't going to be too useful for us here as we don't have our test apps here configured for TestFlight release...

@justinkchen
Copy link

@justinkchen seems like an onerous test cycle. Is the AppStore build not equivalent to a local release build, installed on phone? If not, why not? A reproduction that involves releasing via TestFlight isn't going to be too useful for us here as we don't have our test apps here configured for TestFlight release...

Haha I guess that's what I'm trying to figure out. At first I thought it wasn't working at all until I found the trick of closing and reopening. And yea I'm also unsure why the one on phone is different but I think it's being built in debug mode rather than release? So something maybe in my debug/release specific handling of stuff?

@mikehardy
Copy link
Collaborator

$ /home/mike/work/Invertase/react-native-firebase/tests/node_modules/.bin/react-native run-ios --help

builds your app and starts it on iOS simulator

Options:
  --simulator <string>      Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: "iPhone 6 (10.0)" (default: "iPhone 13")
  --configuration <string>  Explicitly set the scheme configuration to use (default: "Debug")
  --scheme <string>         Explicitly set Xcode scheme to use
  --project-path <string>   Path relative to project root where the Xcode project (.xcodeproj) lives. (default: "ios")
  --device [string]         Explicitly set device to use by name.  The value is not required if you have a single device connected.
  --udid <string>           Explicitly set device to use by udid
  --no-packager             Do not launch packager while building
  --verbose                 Do not use xcbeautify or xcpretty even if installed
  --port <number>            (default: 8081)
  --terminal <string>       Launches the Metro Bundler in a new window using the specified terminal path. (default: "xterm-256color")
  -h, --help                output usage information

Example usage:
  Run on a different simulator, e.g. iPhone SE (2nd generation): 
  react-native run-ios --simulator "iPhone SE (2nd generation)"

  Pass a non-standard location of iOS directory: 
  react-native run-ios --project-path "./app/ios"

  Run on a connected device, e.g. Max's iPhone: 
  react-native run-ios --device "Max's iPhone"

  Run on the AppleTV simulator: 
  react-native run-ios --simulator "Apple TV"  --scheme "helloworld-tvOS"
Done in 1.66s.
mike@bistromath:~/work/Invertase/react-native-firebase/tests (main) % 

npx react-native run-ios --configuration Release --device 'JustinKChens iPhone15Max' ?

@justinkchen
Copy link

i've been running it by just clicking the Play button with my connected phone selected on Xcode GUI (on the top middle), so not sure which command that one runs under the hood

@mikehardy
Copy link
Collaborator

Literally the one I wrote

`npx react-native run-ios --configuration Release --device 'JustinKChens iPhone15Max'

@ROSHANSEBASTIAN
Copy link

jagwingchoy

Hi,
Do you remember what was your firebase packages versions before you downgrade them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: firebase-sdk Pending a confirmed fix landing on the official native sdk's (iOS/Android). platform: ios plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: bug New bug report
Projects
None yet
Development

No branches or pull requests