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.64k stars 2.21k forks source link

[🐛] No sound when get notification on iOS #5651

Closed Deodes closed 3 years ago

Deodes commented 3 years ago

Issue

No sound when getting push notification on iOS device. Device notifications on, silent mode off.


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "MeQRReviewApp", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@invertase/react-native-apple-authentication": "^2.1.2", "@react-native-async-storage/async-storage": "^1.15.5", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/slider": "^3.0.3", "@react-native-firebase/analytics": "^12.1.0", "@react-native-firebase/app": "^12.1.0", "@react-native-firebase/messaging": "^12.1.0", "@react-native-google-signin/google-signin": "^6.0.0", "@react-navigation/bottom-tabs": "^5.11.11", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.5", "axios": "^0.21.1", "moment": "^2.29.1", "react": "17.0.1", "react-native": "0.64.2", "react-native-confirmation-code-field": "^7.1.0", "react-native-device-info": "^8.1.3", "react-native-dotenv": "^2.5.5", "react-native-fbsdk-next": "^4.3.0", "react-native-gesture-handler": "^1.10.3", "react-native-i18n": "^2.0.15", "react-native-keyboard-aware-scroll-view": "^0.9.4", "react-native-localize": "^2.1.1", "react-native-reanimated": "^2.2.0", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.3.0", "react-native-snap-carousel": "^3.9.1", "react-native-sound": "^0.11.0", "react-native-sound-player": "^0.10.9", "react-native-splash-screen": "^3.2.0", "react-native-vector-icons": "^8.1.0", "react-native-video": "^5.1.1", "react-native-video-controls": "^2.8.1", "react-redux": "^7.2.4", "redux": "^4.1.0", "redux-logger": "^3.0.6", "redux-thunk": "^2.3.0", "reselect": "^4.0.0", "validate.js": "^0.13.1" }, "devDependencies": { "@babel/core": "7.14.3", "@babel/runtime": "7.14.0", "@react-native-community/eslint-config": "2.0.0", "babel-jest": "26.6.3", "babel-plugin-module-resolver": "^4.1.0", "eslint": "7.14.0", "jest": "26.6.3", "metro-react-native-babel-preset": "0.64.0", "react-test-renderer": "17.0.1" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "analytics_auto_collection_enabled": true } } ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '10.0' target 'MeQRReviewApp' do config = use_native_modules! use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => false ) target 'MeQRReviewAppTests' do inherit! :complete # Pods for testing end # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. use_flipper!() post_install do |installer| react_native_post_install(installer) end end ``` #### `AppDelegate.m`: ```objc #import #import "AppDelegate.h" #import #import #import #import "RNSplashScreen.h" #import #ifdef FB_SONARKIT_ENABLED #import #import #import #import #import #import static void InitializeFlipper(UIApplication *application) { FlipperClient *client = [FlipperClient sharedClient]; SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client addPlugin:[FlipperKitReactPlugin new]]; [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; } #endif @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FBSDKApplicationDelegate initializeSDK:launchOptions]; //<-- FacebookSDK initialize if ([FIRApp defaultApp] == nil) { // <-- Firebase iOS SDK must be configured during the bootstrap phase of your application [FIRApp configure]; } #ifdef FB_SONARKIT_ENABLED InitializeFlipper(application); #endif [[FBSDKApplicationDelegate sharedInstance] application:application // <-- Connect App Delegate didFinishLaunchingWithOptions:launchOptions]; RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"MeQRReviewApp" initialProperties:nil]; if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; } self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; [RNSplashScreen show]; return YES; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } - (BOOL)application:(UIApplication *)application // <-- Connect App Delegate openURL:(NSURL *)url options:(nonnull NSDictionary *)options { [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options]; return YES; } @end ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 11.5.2 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 75.64 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.0.0 - /usr/local/bin/node Yarn: Not Found npm: 7.19.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 29, 31 Build Tools: 29.0.2, 31.0.0 System Images: android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7486908 Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [x] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase/app` version you're using that has this issue:** - `12.1.0` - **`react-native-firebase/messaging` version you're using that has this issue:** - `12.1.0` - **Are you using `TypeScript`?** - `No`


mikehardy commented 3 years ago

Can you include the actual JSON that you can send to the FCM REST API that triggers this? Include everything but your API key and device token of course

Deodes commented 3 years ago

Found a solution to the problem. Config was not set on the server for notification