Firebase:message:didRefreshRegistrationToken:Category正在实现一个方法,该方法也将由其主类实现

时间:2017-11-06 18:01:49

标签: ios cordova firebase-cloud-messaging cordova-ios

当我在AppDelegate+Firebase.m模块中包含以下委托方法时,我看到上面的消息。

- (void)messaging:(nonnull FIRMessaging *)messaging didRefreshRegistrationToken:(nonnull NSString *)fcmToken {
  ...
}

如果我没有包含委托方法,则应用会在收到令牌刷新时崩溃: -

[FIRA_AppDelegate-1509991141874 messaging:didRefreshRegistrationToken:]: unrecognized selector sent to instance 0x60000003c740'

我之前在application:didFinishLaunchingWithOptions

中设置了委托
[FIRMessaging messaging].delegate = self;

我的问题是,为什么我会看到警告?

我认为"它的小学班级"是AppDelegate,它源自CDVAppDelegate,仅定义application:didFinishLaunchingWithOptions,如下所示:

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
  self.viewController = [[MainViewController alloc] init];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

那么为什么告诉我它将由初级班实施?

修改

RAW警告输出

.../redsky-firebase/AppDelegate+Firebase.m:156:1: warning: category is
      implementing a method which will also be implemented by its primary class [-Wobjc-protocol-method-implementation]
- (void)messaging:(nonnull FIRMessaging *)messaging didRefreshRegistrationToken:(nonnull NSString *)fcmToken {
^
In module 'FirebaseMessaging' imported from .../redsky-firebase/Firebase/Firebase.h:37:
.../redsky-firebase/FirebaseMessaging.framework/Headers/FIRMessaging.h:252:1: note: method
      'messaging:didRefreshRegistrationToken:' declared here
- (void)messaging:(nonnull FIRMessaging *)messaging

来自AppDelegate+Firebase.m:156的代码

// [START refresh_token]
/* If I don't include this, I get an exception saying unrecognised selector - out of date fcm libs? */
- (void)messaging:(nonnull FIRMessaging *)messaging didRefreshRegistrationToken:(nonnull NSString *)fcmToken {
    NSLog(@"FIREBASE: (AppDelegate+Firebase) messaging:didRefreshRegistrationToken: %@", fcmToken);
    [Firebase.firebase sendToken:fcmToken];
}

来自FIRMessaging.h:252的代码

@protocol FIRMessagingDelegate 

/// This method will be called whenever FCM receives a new, default FCM token for your
/// Firebase project's Sender ID.
/// You can send this token to your application server to send notifications to this device.
- (void)messaging:(nonnull FIRMessaging *)messaging
    didRefreshRegistrationToken:(nonnull NSString *)fcmToken
    FIR_SWIFT_NAME(messaging(_:didRefreshRegistrationToken:));

0 个答案:

没有答案