【问题标题】:NO visible interface for FIRMessaging declare the method setRemoteMessageDelegateFIRMessaging 没有可见界面声明方法 setRemoteMessageDelegate
【发布时间】:2016-10-17 20:16:42
【问题描述】:

在使用 FCM tutorial for ios 实现 FCM 消息传递之后,这里是我在 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
    }

这里是 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

我尝试搜索 firemessaging 委托,堆栈上的一些人说不断更新库,它将被修复 here 我无法弄清楚我做错了什么..

【问题讨论】:

  • 你设法让它工作了吗? Firebase 工程师,请更新您的文档。我必须弄清楚很多事情——从让 import 语句正常工作,到 AppDelegate 中的每一行。

标签: ios objective-c firebase google-cloud-messaging firebase-cloud-messaging


【解决方案1】:

我也遇到了同样的错误,但最终我的项目得以构建。检查您的 cocoapods 版本(pod --version)并确保它是最新的。我使用的是 2011 年的 macbook,显然仍在使用古老(低于 1.0.0)版本的 cocoapods。

更新 ruby​​ 后,更新 cocoapods,取消注释“use_frameworks!”在 pod 文件中,运行“pod install”和“pod update”错误消失了。

# 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

【讨论】:

    【解决方案2】:

    当您使用旧版本的云消息传递时会发生该错误。尝试运行:

    pod 更新 --verbose

    【讨论】:

      猜你喜欢
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      相关资源
      最近更新 更多