解析API始终无法访问?

时间:2014-08-08 04:41:26

标签: ios parse-platform reachability

我正在使用Apple的Reachability框架,“api.parse.com”始终无法访问。我错过了什么吗?

在我的viewDidLoad中,我有这个:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];

    self.hostParseReachability = [Reachability reachabilityWithHostName:kParseConnectivityTestURL];
    [self.hostParseReachability startNotifier];
    [self updateInterfaceWithReachability:self.hostParseReachability];

然后我有以下可达性方法:

-(void)reachabilityChanged:(NSNotification* )note
{
    Reachability* curReach = [note object];
    NSParameterAssert([curReach isKindOfClass:[Reachability class]]);
    [self updateInterfaceWithReachability:curReach];
}

- (void)updateInterfaceWithReachability:(Reachability *)reachability {
    NetworkStatus netStatus = [reachability currentReachabilityStatus];

    if (reachability == self.internetReachability) {
        switch (netStatus) {
            case NotReachable:
                isConnectedToInternet = NO;
                break;
            case ReachableViaWWAN:
            case ReachableViaWiFi:
                isConnectedToInternet = YES;
                break;
        }
    }

    if (reachability == self.hostParseReachability) {
        switch (netStatus) {
            case NotReachable:
                isParseOnline = NO;
                break;
            case ReachableViaWWAN:
            case ReachableViaWiFi:
                isParseOnline = YES;
                break;
        }
    }

Parse对我来说总是离线,但我可以执行查询。

1 个答案:

答案 0 :(得分:0)

他们有防火墙阻止ICMP数据包。如果您需要手动检查一切是否正常 - 您可以尝试curl

如果parse无法访问,您将获得kPLParseConnectionFailed(如果是iOs应用)。