Check for connection to leaderboard

0 votes
Hi, I want to check the if the network connection to the leaderboard service is available before using it. Is there anyway to do this? Currently I check if user can access Google. But I am aware of that Google is blocked in some countries. So I need an alternative way to do this. Thanks for your help!
asked Jul 3, 2014 in App42 Cloud API-BaaS by bottle (15 points)

2 Answers

0 votes
 
Best answer

Hi,

The sample provided by Apple checks for three kind of reachability check:

1. Remote Host Reachability

2. Internet Reachability

3. Wi-Fi Reachability

For remote host reachability check, you need to provide host address. But for Internet / Wi-Fi reachability check, there is no need to provide host address. I think in your case, you only need to check for the internet reachability.

If you have downloaded the Sample provided by Apple, go to the viewDidLoad method of APLViewController.m class. You can just replace the viewDidLoad method with the following:

- (void)viewDidLoad

{

    self.summaryLabel.hidden = YES;

    /*

     Observe the kNetworkReachabilityChangedNotification. When that notification is posted, the method reachabilityChanged will be called.

     */

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

      self.internetReachability = [Reachability reachabilityForInternetConnection];

     [self.internetReachability startNotifier];

     [self updateInterfaceWithReachability:self.internetReachability];    

}

Then run the sample, you will see the 2nd option in the Simulator/ device will show you the current internet status. Same thing you can implement in your application.

I hope it will solve the problem.

Thanks.

answered Jul 3, 2014 by rajeev.etc (1,660 points)
selected Jul 4, 2014 by bottle
0 votes
Whch platform SDK you are using? Every platform has native method to check the connection that can be used before making a call.
answered Jul 3, 2014 by ajay123 (899 points)
Thanks for your reply. I am using App42 iOS SDK.
Hi,
Apple has provided Reachability class to check whether the device is connected to the network or not. You can find more details along with a sample project here ( https://developer.apple.com/Library/ios/samplecode/Reachability/Introduction/Intro.html ).
I hope it will help.
Thanks.
Thanks you, rajeev.etc. That's what I am doing now. But testing for accessibility to Google seems not a good way. I think testing for accessibility to leaderboard service hosted server is better. Are there any information about it? Thanks!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...