我正在处理一些Swift和FCM代码,并且在更新了pod之后,我遇到了两个错误。我已经进行了研究,但不知道该怎么做。
代码如下:
// For iOS 10 display notification (sent via APNS)
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
// For iOS 10 data message (sent via FCM)
[FIRMessaging messaging].remoteMessageDelegate = self;
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; error message———> No visible @interface for 'FIRInstanceID' declares the selector 'setAPNSToken:type:'<--error message ends
NSLog(@"deviceToken1 = %@; %@",deviceToken,[[FIRInstanceID instanceID] token]);
}
这是错误消息:
在类型的对象上找不到属性'remoteMessageDelegate' “ FIRMessaging *”
答案 0 :(得分:3)
在5.0.0版中,他们删除了remoteMessageDelegate
并将其替换为delegate
:
https://firebase.google.com/support/release-notes/ios#5.0.0
当前delegate
API文档中的日期也是FIRMessaging
:
https://firebase.google.com/docs/reference/ios/firebasemessaging/api/reference/Classes/FIRMessaging#/c:objc(cs)FIRMessaging(py)delegate
委托以处理FCM令牌刷新和远程数据消息 通过FCM直接渠道收到。
@property (readwrite, nonatomic, nullable) id<FIRMessagingDelegate>
delegate;
您可以参考他们的quickstart-ios代码以获取示例用法:
https://github.com/firebase/quickstart-ios/blob/master/messaging/MessagingExample/AppDelegate.m#L36
// [START set_messaging_delegate]
[FIRMessaging messaging].delegate = self;
// [END set_messaging_delegate]