Zakaria Darwish
Zakaria Darwish

Reputation: 358

NO visible interface for FIRMessaging declare the method setRemoteMessageDelegate

after implementing FCM messaging using FCM tutorial for ios here the code that i use in appdelegate.m

     if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } else {
        // iOS 10 or later
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
        UNAuthorizationOptions authOptions =
        UNAuthorizationOptionAlert
        | UNAuthorizationOptionSound
        | UNAuthorizationOptionBadge;
        [[UNUserNotificationCenter currentNotificationCenter]
         requestAuthorizationWithOptions:authOptions
         completionHandler:^(BOOL granted, NSError * _Nullable error) {
         }
         ];

        // For iOS 10 display notification (sent via APNS)
        [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
        // For iOS 10 data message (sent via FCM)
        [[FIRMessaging messaging] setRemoteMessageDelegate:self]; // here the method is not defined // 
  #endif
    }

here is the appdelegate.h

    //
//  AppDelegate.h
//  lechef
//
//  Created by Zakaria Darwish on 9/5/16.
//  Copyright © 2016 CodeBee. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "constant.h"
#include <AudioToolbox/AudioToolbox.h>
#import "MPGNotification.h"
#include <AudioToolbox/AudioToolbox.h>
#include "constant.h"
@import UserNotifications;
@import GoogleMaps;
@import GooglePlaces;
@import Firebase;
@import FirebaseInstanceID;
@import FirebaseMessaging;

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

and i try to search for firemessaging delegate some people on stack says that keep update the library and it will be fixed here i could not figure out what i am doing wrong ..

Upvotes: 3

Views: 7541

Answers (2)

Nima
Nima

Reputation: 1932

that error happens when you have an older version of cloud messaging. Try running:

pod update --verbose

Upvotes: 0

Ben Harrell
Ben Harrell

Reputation: 123

I was getting this same error too, but finally got my project to build. Check your cocoapods version (pod --version) and make sure it's up to date. I'm using a 2011 macbook and apparently was still using an ancient (lower than 1.0.0) version of cocoapods.

After updating ruby, updating cocoapods, uncommenting "use_frameworks!" in the pod file, running "pod install" and "pod update" the error went away.

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

pod 'Firebase/Core'
pod 'Firebase/Messaging'

target 'myappname' do

end

target 'myappnameTests' do

end

Upvotes: 3

Related Questions