草庐IT

ios - [Firebase/Core][I-COR000020] 发布到 Clearcut : Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline 时出错

coder 2023-09-23 原文

我使用 FireBase SDK 作为我的应用程序的后端,并且我已根据需要启用了持久性。

[FIRDatabase database].persistenceEnabled = YES;

离线模式一直运行良好,直到最近我在离线模式下使用我的应用程序时开始收到此错误。

2017-01-08 19:03:44.838 MyApp[1002] <Error> [Firebase/Core][I-COR000020] Error posting to Clearcut: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x170056710 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}, with Status Code: 0

这很容易重现。只需在 iPhone 的飞行模式之间切换,您就会看到此错误。

我正在使用 CocoaPods 来使用 FireBase,这里是框架列表及其版本。

-> Using Firebase (3.11.0)

-> Using FirebaseAnalytics (3.6.0)

-> Using FirebaseAuth (3.1.0)

-> Using FirebaseCore (3.4.6)

-> Using FirebaseDatabase (3.1.1)

-> Using FirebaseInstanceID (1.0.8)

最佳答案

我无法修复 firebase 代码,但我能够将其包装在异常处理中,以防止它在设备上的互联网连接关闭时崩溃我的应用程序(特别是在 iPad2 上)。

objective-c

            @try {
            [FIRAnalytics logEventWithName:@"share" parameters:@{
        @"item_id" : [[[StatusReportIAPHelper sharedInstance] product] productIdentifier],
                 @"content_type" : @{@"title": [[[StatusReportIAPHelper sharedInstance] product] localizedTitle]}
              }];
             }
             @catch (NSException* exception) {
                 NSLog(@"SRS.logEventWithName Exception: %@ Reason: %@", exception.name, exception.reason);
             }

swift 4

        do {
                Analytics.logEvent(AnalyticsEventSelectContent, parameters: [
                    AnalyticsParameterItemID: "id-\(bundleID!)" as NSObject
                    , AnalyticsParameterItemName: "\(bundleID!)" as NSObject
                    , AnalyticsParameterContentType:
                        "\(unquotedAppname!)" as NSString])
                }
                catch {
                    NSLog("POAD.logEvent Cannot log event - no Internet connection");
                }

关于ios - [Firebase/Core][I-COR000020] 发布到 Clearcut : Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41540560/

有关ios - [Firebase/Core][I-COR000020] 发布到 Clearcut : Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline 时出错的更多相关文章

随机推荐