Ios @react-native firebase/messaging:TypeError:(0,_messaging.default)(…)。registerForRemoteNotifications不是函数
我正在使用@react native firebase/app“^8.2.0”、@react native firebase/messaging和react native v0.61.0。 同时使用@react-native community/push notification ios“^1.4.0”和“react-native push notification”:“^4.0.0” 我最近将react本机版本从0.63.0降级为0.61.0。在安卓系统中,一切都很完美,但在ios模拟器和real device中,Ios @react-native firebase/messaging:TypeError:(0,_messaging.default)(…)。registerForRemoteNotifications不是函数,ios,react-native,push-notification,react-native-firebase,Ios,React Native,Push Notification,React Native Firebase,我正在使用@react native firebase/app“^8.2.0”、@react native firebase/messaging和react native v0.61.0。 同时使用@react-native community/push notification ios“^1.4.0”和“react-native push notification”:“^4.0.0” 我最近将react本机版本从0.63.0降级为0.61.0。在安卓系统中,一切都很完美,但在ios模拟器和re
messaging()。registerforremotentifications()
throw error
TypeError:(0,_messaging.default)(…)。registerForRemoteNotifications不是函数
TypeError:(0,_messaging.default)(…)。registerForRemoteNotifications不是函数
在App.componentDidMount
反应本地信息
系统:
操作系统:macOS 10.15.5
CPU:(4)x64 Intel(R)Core(TM)i5-3470S CPU@2.90GHz
内存:45.55 MB/16.00 GB
Shell:3.2.57-/bin/bash
二进制文件:
节点:12.15.0-/usr/local/bin/Node
npm:6.13.4-/usr/local/bin/npm
看守人:4.9.0-/usr/local/bin/Watchman
SDK:
iOS SDK:
平台:iOS 13.5、DriverKit 19.0、macOS 10.15、tvOS 13.4、watchOS 6.2
IDE:
Xcode:11.5/11E608c-/usr/bin/Xcode构建
NPM包装:
反应:16.9.0=>16.9.0
反应本机:0.61.0=>0.61.0
npmGlobalPackages:
react本机cli:2.0.1
我的App.js
文件
const hasPermissions = await messaging().hasPermission()
if (hasPermissions) {
await messaging().registerForRemoteNotifications()
await new Promise((resolve, reject) => setTimeout(() => resolve(), 1000))
token = await messaging().getToken()
let fctk = `getting fcm token ${token}`
Alert.alert(fctk)
console.log('FCM token', token)
} else {
const { status } = await requestNotifications(['alert', 'sound'])
if (status === 'granted') {
await messaging().registerForRemoteNotifications()
await new Promise((resolve, reject) => setTimeout(() => resolve(), 1000))
token = await messaging().getToken()
let fctk = `getting fcm token ${token}`
Alert.alert(fctk)
console.log('FCM token has been received', token)
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Firebase.h>
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import <GoogleMaps/GoogleMaps.h>
#import "RNSplashScreen.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
[GMSServices provideAPIKey:@"AIzaSyBALbK0zTosrX4J1sl9-k1wJt14Zuwk37M"];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"APPBusinessPlaza63"
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];
// Define UNUserNotificationCenter
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[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
}
// 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];
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}
@end
我的AppDelegate.m
文件
const hasPermissions = await messaging().hasPermission()
if (hasPermissions) {
await messaging().registerForRemoteNotifications()
await new Promise((resolve, reject) => setTimeout(() => resolve(), 1000))
token = await messaging().getToken()
let fctk = `getting fcm token ${token}`
Alert.alert(fctk)
console.log('FCM token', token)
} else {
const { status } = await requestNotifications(['alert', 'sound'])
if (status === 'granted') {
await messaging().registerForRemoteNotifications()
await new Promise((resolve, reject) => setTimeout(() => resolve(), 1000))
token = await messaging().getToken()
let fctk = `getting fcm token ${token}`
Alert.alert(fctk)
console.log('FCM token has been received', token)
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Firebase.h>
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import <GoogleMaps/GoogleMaps.h>
#import "RNSplashScreen.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
[GMSServices provideAPIKey:@"AIzaSyBALbK0zTosrX4J1sl9-k1wJt14Zuwk37M"];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"APPBusinessPlaza63"
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];
// Define UNUserNotificationCenter
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[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
}
// 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];
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}
@end
CfBundledDevelopmentRegion
EN
CbundleDisplayName
$(产品名称)
Cbundlexecutable
$(可执行文件名称)
CbundleIdentifier
$(产品\捆绑包\标识符)
CbundleInfo字典版本
6
CFBundleName
$(产品名称)
CbundlePackageType
应用
CbundleShortVersionString
1
CFBundleSignature
????
CbundleurlTypes
CbundleTypeRole
编辑
CFBundleURLName
束ID
循环流化床锅炉方案
com.webmascot.bp
CbundleTypeRole
编辑
循环流化床锅炉方案
com.googleusercontent.apps.558394662083-PO8OKPLHV0CVC91R76RKAU73TDDKPJ7
CbundleTypeRole
编辑
循环流化床锅炉方案
fb469065720287765
循环流化床锅炉
1.
LSREQUIRESPHONEOS
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSExceptionDomains
本地服务器
N异常低安全Http负载
NSLocationWhenUse用途说明
UIAppFonts
Axiforma_Bold.ttf
Axiforma_Book.ttf
Axiforma_Light.ttf
Axiforma_Medium.ttf
Axiforma_Regular.ttf
唯物主义者
MaterialCommunicationIcons.ttf
Poppins-Black.ttf
Poppins-BlackItalic.ttf
Poppins-Bold.ttf
Poppins-BoldItalic.ttf
Poppins-ExtraBold.ttf
Poppins-ExtraBoldItalic.ttf
Poppins-ExtraLight.ttf
Poppins-ExtraLightItalic.ttf
Poppins-Italic.ttf
Poppins-Light.ttf
Poppins-LightItalic.ttf
Poppins-Medium.ttf
Poppins-MediumItalic.ttf
Poppins-Regular.ttf
Poppins-SemiBold.ttf
Poppins-SemiBoldItalic.ttf
Poppins-Thin.ttf
Poppins-ThinItalic.ttf
Roboto-Black.ttf
Roboto-BlackItalic.ttf
Roboto-Bold.ttf
Roboto-BoldItalic.ttf
Roboto-Italic.ttf
Roboto-Light.ttf
Roboto-Medium.ttf
Roboto-Regular.ttf
Roboto-Thin.ttf
Roboto_medium.ttf
机器人
rubicon-icon-font.ttf
UIBackgroundModes
取来
远程通知
UILaunchStoryboardName
发射屏
UIRequiredDeviceCapabilities
armv7
UI支持接口方向
UIInterfaceOrientationPortrait
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight
UIViewControllerBasedStatusBarAppearance
您找到解决此问题的方法了吗?@GautamShrivastav是的,那么@GautamShrivastav的解决方法是什么?