作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在使用 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 delegate 堆栈上的一些人说继续更新库,它将被修复 here我不知道我做错了什么..
最佳答案
我也遇到了同样的错误,但最终还是构建了我的项目。检查您的 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
关于ios - 没有可见的 FIRMessaging 接口(interface)声明方法 setRemoteMessageDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40094927/
在使用 FCM tutorial for ios 实现 FCM 消息传递之后这是我在 appdelegate.m 中使用的代码 if (floor(NSFoundationVersionNu
我是一名优秀的程序员,十分优秀!