【问题标题】:Firebase intergration error in IOSIOS中的Firebase集成错误
【发布时间】:2018-03-14 10:40:48
【问题描述】:

我在我的应用程序中集成了 firebase 推送通知。我已经很好地安装了 cocoapods,并在 appdelegate.m 文件中为 firebase 消息传递执行了所有代码。还创建了证书并上传到我的项目的firebase,我正确地遵循了所有程序,但是当我运行应用程序时,我遇到了一些错误并且应用程序没有运行并在链接时显示错误。我的 firebase 代码是这样的,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        [FIRApp configure];

        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(tokenRefreshCallBack:) name:kFIRInstanceIDTokenRefreshNotification object:nil];

        UIUserNotificationType type=(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
        UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:type categories:nil];

        [application registerUserNotificationSettings:settings];
        [application registerForRemoteNotifications];
        return YES;
    }

    -(void)tokenRefreshCallBack:(NSNotification *)notification{
        NSString *refreshToken=[[FIRInstanceID instanceID]token];
        NSLog(@"Instance IDToken : %@",refreshToken);
        [self connecttoFirebase];
    }

    -(void)connecttoFirebase{
        [[FIRMessaging messaging]connectWithCompletion:^(NSError * _Nullable error){
            if (error !=nil) {
            NSLog(@"Unable to connect to FCM %@",error);
            }else{
            NSLog(@"Connected to FCM");
            }
            }];
    }

    -(void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
        NSLog(@"Message ID : %@",userInfo[@"gcm.message_id"]);
        NSLog(@"%@",userInfo);
    }

enter image description here

enter image description here

【问题讨论】:

  • 您的应用支持的最小 ios 版本是什么?
  • 我的应用程序的 10.0 版本。 @AbdulKarim
  • 我们可以看看你的 podfile 吗?您是否尝试通过注释掉您的 Firebase、pod install,然后再次取消注释 pod 和 pod install 来重新安装您的 Firebase pod?
  • 我已经添加了屏幕截图检查。 @格伦
  • 检查是否正常。 @格伦

标签: ios objective-c firebase


【解决方案1】:

David East 爵士的回答 (https://stackoverflow.com/a/38226058/3231194):

转到Build Settings > Other Linker Flags > 换行$(inherited)

执行Cmd+Ctrl+K 进行清理,然后构建。


我也想添加这些步骤,而不是Cmd+Ctrl+K,应该是:

  1. Cmd+Shift+K。然后:
  2. Cmd+AltOption+Shift+K
  3. 最后,构建它。

【讨论】:

  • 兄弟我已经完成了这个过程,当我这样做时,我很快就得到了一个未知参数的错误。 @格伦
  • 兄弟,在我的问题中执行上述程序检查后,我添加了屏幕截图。 @格伦
  • 在 Build Settings > Other Linker Flags 中移除 -swift
  • 当我删除它时,它会向我显示 5 条错误消息,就像我有问题的屏幕截图一样。 @priyadharshini
  • @Raheel 您是否尝试过更新您的Cocoapod,然后更新您的 Xcode 的 pod?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-27
  • 2020-08-26
  • 2013-03-26
  • 2017-02-16
  • 2016-01-22
  • 2018-04-12
  • 2014-07-31
相关资源
最近更新 更多