iOS Cloud Messaging module error (no known class method for selector […])

Trying to run cloud messaging in my app. It worked well for android, but I cannot make it working for iOS. iOS app doesn’t compile and I get these errors:

In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:14:
In file included from /Users/lukaleli/Dev/myApp/ios/../node_modules/react-native-config/ios/ReactNativeConfig/ReactNativeConfig.h:2:
../node_modules/react-native/React/Base/RCTBridgeModule.h:55:11: warning: duplicate protocol definition of 'RCTBridgeModule' is ignored
@protocol RCTBridgeModule <NSObject>
          ^
In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:13:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTRootView.h:12:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridge.h:13:
/Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridgeModule.h:55:11: note: previous definition is here
@protocol RCTBridgeModule <NSObject>
          ^
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:66:24: error: no known class method for selector 'willPresentNotification:withCompletionHandler:'
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:72:24: error: no known class method for selector 'didReceiveNotificationResponse:withCompletionHandler:'
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.


** BUILD FAILED **



The following build commands failed:
	CompileC build/Build/Intermediates/goodly.build/Debug-iphonesimulator/goodly.build/Objects-normal/x86_64/AppDelegate.o goodly/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/myApp.app
Launching <MY.APP.IDENTIFIER>
<MY.APP.IDENTIFIER>: 43571

My setup

Podfile

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

target 'goodly' do
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'

end

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "ReactNativeConfig.h"
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Firebase.h>
#import "RNFirebaseMessaging.h"

@import GoogleMaps;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSString *GOOGLE_MAPS_API_KEY = [ReactNativeConfig envFor:@"GOOGLE_MAPS_API_KEY"];
  NSURL *jsCodeLocation;
  [GMSServices provideAPIKey:GOOGLE_MAPS_API_KEY];
  [BugsnagReactNative start];
  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"wertewandel"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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];
  return YES;
}

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFirebaseMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)())completionHandler {
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

@end

AppDelegate.h

#import <UIKit/UIKit.h>
@import UserNotifications;

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

I did pod install after adding cloud messaging module, did fresh install with rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install. Am I missing something?

Any help would be greatly appreciated!

Environment

  1. Target Platform: iOS
  2. Development Operating System : macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
  4. React Native version: 0.41.2
  5. RNFirebase Version: 2.0.2

Author: Fantashit

2 thoughts on “iOS Cloud Messaging module error (no known class method for selector […])

Comments are closed.

iOS Cloud Messaging module error (no known class method for selector […])

Trying to run cloud messaging in my app. It worked well for android, but I cannot make it working for iOS. iOS app doesn’t compile and I get these errors:

In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:14:
In file included from /Users/lukaleli/Dev/myApp/ios/../node_modules/react-native-config/ios/ReactNativeConfig/ReactNativeConfig.h:2:
../node_modules/react-native/React/Base/RCTBridgeModule.h:55:11: warning: duplicate protocol definition of 'RCTBridgeModule' is ignored
@protocol RCTBridgeModule <NSObject>
          ^
In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:13:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTRootView.h:12:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridge.h:13:
/Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridgeModule.h:55:11: note: previous definition is here
@protocol RCTBridgeModule <NSObject>
          ^
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:66:24: error: no known class method for selector 'willPresentNotification:withCompletionHandler:'
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:72:24: error: no known class method for selector 'didReceiveNotificationResponse:withCompletionHandler:'
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.


** BUILD FAILED **



The following build commands failed:
	CompileC build/Build/Intermediates/goodly.build/Debug-iphonesimulator/goodly.build/Objects-normal/x86_64/AppDelegate.o goodly/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/myApp.app
Launching <MY.APP.IDENTIFIER>
<MY.APP.IDENTIFIER>: 43571

My setup

Podfile

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

target 'goodly' do
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'

end

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "ReactNativeConfig.h"
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Firebase.h>
#import "RNFirebaseMessaging.h"

@import GoogleMaps;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSString *GOOGLE_MAPS_API_KEY = [ReactNativeConfig envFor:@"GOOGLE_MAPS_API_KEY"];
  NSURL *jsCodeLocation;
  [GMSServices provideAPIKey:GOOGLE_MAPS_API_KEY];
  [BugsnagReactNative start];
  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"wertewandel"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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];
  return YES;
}

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFirebaseMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)())completionHandler {
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

@end

AppDelegate.h

#import <UIKit/UIKit.h>
@import UserNotifications;

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

I did pod install after adding cloud messaging module, did fresh install with rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install. Am I missing something?

Any help would be greatly appreciated!

Environment

  1. Target Platform: iOS
  2. Development Operating System : macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
  4. React Native version: 0.41.2
  5. RNFirebase Version: 2.0.2

Author: Fantashit

2 thoughts on “iOS Cloud Messaging module error (no known class method for selector […])

Comments are closed.

iOS Cloud Messaging module error (no known class method for selector […])

Trying to run cloud messaging in my app. It worked well for android, but I cannot make it working for iOS. iOS app doesn’t compile and I get these errors:

In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:14:
In file included from /Users/lukaleli/Dev/myApp/ios/../node_modules/react-native-config/ios/ReactNativeConfig/ReactNativeConfig.h:2:
../node_modules/react-native/React/Base/RCTBridgeModule.h:55:11: warning: duplicate protocol definition of 'RCTBridgeModule' is ignored
@protocol RCTBridgeModule <NSObject>
          ^
In file included from /Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:13:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTRootView.h:12:
In file included from /Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridge.h:13:
/Users/lukaleli/Dev/myApp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridgeModule.h:55:11: note: previous definition is here
@protocol RCTBridgeModule <NSObject>
          ^
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:66:24: error: no known class method for selector 'willPresentNotification:withCompletionHandler:'
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lukaleli/Dev/myApp/ios/myApp/AppDelegate.m:72:24: error: no known class method for selector 'didReceiveNotificationResponse:withCompletionHandler:'
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.


** BUILD FAILED **



The following build commands failed:
	CompileC build/Build/Intermediates/goodly.build/Debug-iphonesimulator/goodly.build/Objects-normal/x86_64/AppDelegate.o goodly/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/myApp.app
Launching <MY.APP.IDENTIFIER>
<MY.APP.IDENTIFIER>: 43571

My setup

Podfile

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

target 'goodly' do
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS

  # Required by RNFirebase
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'

end

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "ReactNativeConfig.h"
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Firebase.h>
#import "RNFirebaseMessaging.h"

@import GoogleMaps;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSString *GOOGLE_MAPS_API_KEY = [ReactNativeConfig envFor:@"GOOGLE_MAPS_API_KEY"];
  NSURL *jsCodeLocation;
  [GMSServices provideAPIKey:GOOGLE_MAPS_API_KEY];
  [BugsnagReactNative start];
  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"wertewandel"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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];
  return YES;
}

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFirebaseMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)())completionHandler {
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

@end

AppDelegate.h

#import <UIKit/UIKit.h>
@import UserNotifications;

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

I did pod install after adding cloud messaging module, did fresh install with rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install. Am I missing something?

Any help would be greatly appreciated!

Environment

  1. Target Platform: iOS
  2. Development Operating System : macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
  4. React Native version: 0.41.2
  5. RNFirebase Version: 2.0.2

Author: Fantashit

2 thoughts on “iOS Cloud Messaging module error (no known class method for selector […])

Comments are closed.