ios - 'FIRInstanceID' 没有可见的@interface 声明选择器 'setAPNSToken:type:'

标签 ios firebase firebase-cloud-messaging

更新 Pod 库后 appdelegate.m 出现上述错误

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {

    [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
    NSString *newToken = [deviceToken description];
    newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
    newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@"My token is: %@", newToken);

}

最佳答案

这是已弃用的代码,您应该尝试使用 FIRMessaging

您可以将代码更新为如下所示

// With "FirebaseAppDelegateProxyEnabled": NO
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [FIRMessaging messaging].APNSToken = deviceToken;
}

引用here了解更多详情。

关于ios - 'FIRInstanceID' 没有可见的@interface 声明选择器 'setAPNSToken:type:',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53078653/

相关文章:

ios - 检测字符串的语言

ios - 链接多对多的对象应该都写在 Realm 中吗?

ios - 在另一个手势识别器触发时暂时禁用一个手势识别器

node.js - 使用 Firestore 云函数

javascript - Firebase 函数问题以及 .add() 与 .doc().set() 之间的区别

android - 使用 Firebase http v1 api 向多个设备发送消息

ios - RGBA 到 ABGR : Inline arm neon asm for iOS/Xcode

firebase - 云函数 "call"API限制

Android:Firebase - 多个发件人将通知推送到特定设备

firebase - FirebaseAppDelegateProxyEnabled 有什么作用?