2

使用FCM tutorial for ios這裏,我在appdelegate.m爲FIRMessaging NO可見接口聲明方法setRemoteMessageDelegate

 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 
實施 FCM消息後

我試圖搜索firemessaging委託堆棧上的一些人說,保持更新庫,它將被修復here我無法弄清楚我做錯了什麼..

+1

您是否設法讓此工作正常運行? Firebase工程師請更新您的文檔。我必須弄清楚很多事情 - 從導入聲明到工作,到AppDelegate中的每一行。 –

回答

2

我也得到這個相同的錯誤,但最終讓我的項目建立。檢查您的cocoapods版本(pod --version)並確保它是最新的。我使用的是2011年的macbook,顯然還在使用古代(低於1.0.0)版本的cocoapods。

更新紅寶石後,更新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 
0

當您擁有較舊版本的雲消息時會發生錯誤。嘗試運行:

pod update --verbose

相關問題