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.53k stars 2.19k forks source link

iOS 14 requestPermission failure if iOS product name has non-English characters #4093

Closed xyzlast closed 3 years ago

xyzlast commented 3 years ago

Issue

First. I have no error in iOS 12/13 now. but iOS 14 Beta4 push notification permission failed.

Exception thrown when 'await messaging().requestPermission();' is called.

when requestPermission() called, didFailtoRegisterForRemoteNotificationsWithError received nil error. here is the code.

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  //error is nil! why?
  [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}

Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "", "version": "1.5.0", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "postinstall": "cjk-textinput-patch", "postuninstall": "cjk-textinput-patch" }, "dependencies": { "@actbase/react-native-kakao-channel": "^1.0.1", "@actbase/react-native-kakao-login": "^1.0.5", "@actbase/react-native-kakaosdk": "^1.3.6", "@invertase/react-native-apple-authentication": "^1.1.2", "@react-native-community/async-storage": "^1.9.0", "@react-native-community/datetimepicker": "^2.4.2", "@react-native-community/google-signin": "^4.0.3", "@react-native-community/masked-view": "^0.1.8", "@react-native-community/push-notification-ios": "^1.4.0", "@react-native-firebase/app": "^8.3.0", "@react-native-firebase/messaging": "^7.6.1", "@react-navigation/drawer": "^5.4.1", "@react-navigation/native": "^5.1.5", "@react-navigation/stack": "^5.2.10", "axios": "^0.19.2", "immer": "^6.0.3", "moment": "^2.26.0", "native-base": "2.13.12", "react": "16.11.0", "react-native": "0.62.2", "react-native-animated-bar": "^0.2.0", "react-native-biometrics": "^2.1.4", "react-native-code-push": "^6.2.0", "react-native-daum-postcode": "^1.0.9", "react-native-deep-linking": "^2.2.0", "react-native-device-info": "^5.5.5", "react-native-dialog": "^5.6.0", "react-native-exit-app": "^1.1.0", "react-native-fs": "^2.16.6", "react-native-gesture-handler": "^1.6.1", "react-native-global-props": "^1.1.5", "react-native-image-picker": "^2.3.1", "react-native-image-resizer": "^1.2.1", "react-native-keyboard-aware-scroll-view": "^0.9.1", "react-native-linear-gradient": "^2.5.6", "react-native-loading-spinner-overlay": "^1.1.0", "react-native-modal": "^11.5.6", "react-native-modal-datetime-picker": "^8.7.1", "react-native-reanimated": "^1.8.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.4.0", "react-native-swiper": "^1.6.0", "react-native-vector-icons": "6.6.0", "react-native-webview": "^10.3.1", "react-native-youtube-iframe": "^1.2.4", "react-redux": "^7.2.0", "redux-actions": "^2.6.5", "redux-saga": "^1.1.3", "rn-secure-storage": "^2.0.4" }, "devDependencies": { "@babel/core": "7.9.0", "@babel/runtime": "7.9.2", "@react-native-community/eslint-config": "0.0.5", "babel-jest": "24.9.0", "eslint": "6.8.0", "jest": "24.9.0", "metro-react-native-babel-preset": "0.58.0", "react-native-cjk-textinput-patch": "^1.0.0", "react-test-renderer": "16.11.0", "redux-devtools-extension": "^2.13.8" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby platform :ios, '11.1' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' def add_flipper_pods!(versions = {}) versions['Flipper'] ||= '~> 0.33.1' versions['DoubleConversion'] ||= '1.1.7' versions['Flipper-Folly'] ||= '~> 2.1' versions['Flipper-Glog'] ||= '0.3.6' versions['Flipper-PeerTalk'] ||= '~> 0.0.4' versions['Flipper-RSocket'] ||= '~> 1.0' pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug' # List all transitive dependencies for FlipperKit pods # to avoid them being linked in Release builds pod 'Flipper', versions['Flipper'], :configuration => 'Debug' pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug' pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug' pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug' pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug' pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug' pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug' pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug' end # Post Install processing for Flipper def flipper_post_install(installer) installer.pods_project.targets.each do |target| if target.name == 'YogaKit' target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '4.1' end end end end target 'GoGold' do # Pods for GoGold pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' use_native_modules! # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. add_flipper_pods! pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient' post_install do |installer| flipper_post_install(installer) end end ``` #### `AppDelegate.m`: ```objc #import #import #import "AppDelegate.h" #import #import #import #import #import #import #if DEBUG #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 { #if DEBUG InitializeFlipper(application); #endif if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"GoGold" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; return YES; } -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [CodePush bundleURL]; #endif } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([KOSession isKakaoAccountLoginCallback:url]) { return [KOSession handleOpenURL:url]; } return false; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { if ([KOSession isKakaoAccountLoginCallback:url]) { return [KOSession handleOpenURL:url]; } return false; } - (void)applicationDidBecomeActive:(UIApplication *)application { [KOSession handleDidBecomeActive]; } // Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; } // IOS 10+ Required for localNotification event - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { [RNCPushNotificationIOS didReceiveNotificationResponse:response]; completionHandler(); } // IOS 4-10 Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RNCPushNotificationIOS didReceiveLocalNotification:notification]; } @end ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - firebase/app: 8.3.0 - **`Firebase` module(s) you're using that has the issue:** - firebase/messaging: 7.6.1 - **Are you using `TypeScript`?** - NO


mikehardy commented 3 years ago

What is RNCPushNotificationIOS ? How is that related to this library?

Have you tried mitigating at all via use of react-native-permissions?

xyzlast commented 3 years ago

What is RNCPushNotificationIOS ? How is that related to this library?

Have you tried mitigating at all via use of react-native-permissions?

xyzlast commented 3 years ago

What is RNCPushNotificationIOS ? How is that related to this library?

Have you tried mitigating at all via use of react-native-permissions?

I migrated all via use react-native-permissions. and so I have this error message.

Error: Notifications are not allowed for this application

but. iOS 13, 12 I do not have this error message shown. Hmm...... Do you know this reason? I don't have the other way to solve it;

mikehardy commented 3 years ago

@xyzlast perhaps this is related to your project config? In Xcode and the in the entitlements for the app on the apple developer website you have to enable notifications

xyzlast commented 3 years ago

@xyzlast perhaps this is related to your project config? In Xcode and the in the entitlements for the app on the apple developer website you have to enable notifications

No. This is not project config issue. I do not have error in iOS 12, 13. I dont have any solution for this situation. -_-

env: iPhone SE2 (I have one test phone.);;

mikehardy commented 3 years ago

We haven't heard any other reports of this, and your Podfile looks suspect in the sense that it does not look like it's correctly upgraded to current react-native, at the same time I'm not sure how the notification package is supposed to integrate since it is out of this module. If you can reproduce the problem in a simple throwaway/reproduction app using just react-native-firebase and sending pushes with notification payload from the console fails, then we could try your repro app out and isolate any problem

YounghoonYun commented 3 years ago

Same issue in my application.

mikehardy commented 3 years ago

@YounghoonYun please open a fresh issue - this one had a lot of not-correct-looking things in the information provided, and we have new versions of the libraries out as well. If you can include a minimal reproduction App.js that would be best, and stack trace is needed for the crash

hellojunha commented 3 years ago

Did you found the solution? I have same issue too even though I'm not using react native (pure Swift project)

hellojunha commented 3 years ago

OK I solved this issue by changing product name in Xcode. Mine was written in Korean and that was the problem. Try change that field into English

mikehardy commented 3 years ago

@joona0825 that is unexpected but great information thank you for circling back! original reporter is likely in non-ASCII character set as well. Is there any documentation in related libraries (firebase-ios-sdk or similar) that document restrictions in name character set? 🤔

redgun524 commented 3 years ago

@joona0825 Thank you very much! I changed the [Build Settings-Product Name] to English and it works fine. It's just a problem with product name... It's ridiculous, but it's still good

mikehardy commented 3 years ago

For anyone affected - I'm not sure where the documentation is for the APIs you are using (it seems like perhaps react-native-permissions? perhaps react-native-community/push-notifications-ios?) but GitHub makes it very easy to do a documentation PR if you just click the edit button at the top right of the file on github. Documenting that this is important might save future developers a lot of time!

Closing this now as there doesn't appear to be anything we can do in this module

hellojunha commented 3 years ago

@mikehardy I could not found any documentation. Only thing I guess is it's iOS side issue, not about both Firebase or react native.

rwichmann commented 3 years ago

I can confirm that special characters in "Product Name" in iOS 14 cause this bug. Unfortunately this also happens to previously deployed apps built with Xcode 11.x. So this seems to be unrelated to react-native-firebase and seems to be an iOS 14 issue.

mikehardy commented 3 years ago

@rwichmann that is great to hear confirmation but also terrible news that it exists as a problem. I can only recommend opening an issue with Apple (if one is not already open). Thank you very much for confirming

(this is marked as "Resolution: Solution Provided" which is true but I understand the solution is ridiculous, it's just not in our control, sorry)

trananhtuat commented 3 years ago

My app Product name is English, but it can't receive notification on iOS 14

mikehardy commented 3 years ago

@trananhtuat there is a mildly related issue in #4299 that may have bearing on your case. It should be conclusively fixed if you can update to the most recent (just released) versions of the react-native-firebase packages. That should be possible unless you're using on-device machine language inference and can't adopt the ML package breaking changes yet

RahulLadybirdweb commented 3 years ago

solution:-

  1. xcode -> file -> new -> target.. -> notification service extansion -> Next -> fill up all the value -> activete